locked
Server lookup using XL RRS feed

  • Question

  • Hi

    I would like to use XL to lookup server information, I have a script that looks up user info below, but would like to use the same script to look up servers in the same way. Can anyone help?

    
    Sub Get_User()
    
    Const ADS_NAME_INITTYPE_GC = 3
    Const ADS_NAME_TYPE_NT4 = 3
    Const ADS_NAME_TYPE_1779 = 1
    
    Dim strNTName As String
    Dim HomeDirectory As String
    Dim ExchangeServer As String
    Dim Description As String
    Dim Company As String
    Dim Dept As String
    Dim Title As String
    Dim City As String
    Dim AccDis As String
    Dim Fullname As String
    Dim objTrans As New NameTranslate
    Dim strUserDN As String
    Dim objUser As Object
    Dim AFArray() As String
    Dim I As Integer
     I = 2
    Do While Range("A" & I).Text <> ""
    On Error Resume Next
    strNTName = Trim("mydomain\" & Range("A" & I).Text)
    Set objTrans = CreateObject("NameTranslate")
    objTrans.Init ADS_NAME_INITTYPE_GC, ""
    objTrans.Set ADS_NAME_TYPE_NT4, strNTName
    strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
    
    Set objUser = GetObject("LDAP://" & strUserDN)
    HomeDirectory = objUser.HomeDirectory
    ExchangeServer = objUser.msExchHomeServerName
    Description = objUser.Description
    AccDis = objUser.AccountDisabled
    Fullname = objUser.DisplayName
    City = objUser.l
    Dept = objUser.Department
    Title = objUser.Title
    Company = objUser.Company
    Alias = objUser.mailNickname
    homePhone = objUser.homePhone
    TelephoneNumber = objUser.TelephoneNumber
    mobile = objUser.mobile
    Email = objUser.proxyAddresses
    FirstName = objUser.givenName
    Surname = objUser.sn
    employeeNumber = objUser.employeeNumber
    co = objUser.co
    
    
    If Err.Number <> 0 Then
        Range("B" & I).Value = "USER ID IS WRONG"
    Else
        'on error goto 0
        AFArray() = Split(objUser.Parent, ",")
        
        Select Case UBound(AFArray())
        Case 7
            sSite = AFArray(1)
        Case 8
            sSite = Mid(AFArray(0), 8, 6)
        End Select
    
        Range("B" & I).Value = Alias
        Range("C" & I).Value = FirstName
        Range("D" & I).Value = Surname
        Range("E" & I).Value = employeeNumber
        Range("F" & I).Value = sSite
        Range("G" & I).Value = Fullname
        Range("H" & I).Value = Title
        Range("I" & I).Value = Dept
        Range("J" & I).Value = Company
        Range("K" & I).Value = City
        Range("L" & I).Value = TelephoneNumber
        Range("M" & I).Value = homePhone
        Range("N" & I).Value = mobile
        Range("O" & I).Value = AccDis
        Range("P" & I).Value = Description
        Range("Q" & I).Value = co
        
        
    
        
        
    End If
    I = I + 1
    Loop
     
    
    
    End Sub

    
    • Moved by Bill_Stewart Friday, August 1, 2014 3:53 PM Move to more appropriate forum
    • Moved by Luna Zhang - MSFT Wednesday, August 6, 2014 2:11 AM VBA related rather than Excel
    Friday, August 1, 2014 3:09 PM

All replies

  • Are you sure this question is about Excel. I think your question is about how to write a script to look up Web servers, which is not about to Office development.

    Monday, August 4, 2014 10:00 AM