dcsimg
Results 1 to 2 of 2

Thread: need to Search AD by sAMAccountName and display hidden property employeeID

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    2

    need to Search AD by sAMAccountName and display hidden property employeeID

    I am trying to query AD by sAMAccountName then get the employeeID attribute for that account and display it in a msgbox. This is a simple task in powershell, but I have been asked to make it run in an XP environment with native WSH, so multiple installs of powershell are not needed for people that will only use it for this one task. Here is what I have so far, but I keep geeting an error and I can't find where my syntax is incorrect:

    Const ADS_SCOPE_SUBTREE = 2
    Dim strSamName,strEmpID

    strSamName = ""
    'Get User Info
    strSamName = InputBox ("Enter user's SamAccountName","SamAccount Input")
    'MsgBox strSamName & " was entered",0,"Account Info"
    if Len(Trim(strSamName))=0 then
    msgbox "Nothing Entered!",0,"ERROR"
    else
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand = CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    objCommand.CommandText = _
    "SELECT sAMAccountName FROM 'LDAP://OU=ChildOU,OU=ParentOU,DC=accounts,DC=Company,DC=ca,DC=com' WHERE " _
    & "sAMAccountName='" & strSamName
    Set objRecordset = objCommand.Execute
    strEmpID = objRecordset.Fields("employeeID")
    MsgBox strSamName & "has employee id of " & strEmpID
    End If

    Any help would be greatly appreciated.

  2. #2

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    2

    Re: need to Search AD by sAMAccountName and display hidden property employeeID

    Not sure if it will help but here is the error I am receiving.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width