|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pulling Active Directory info into an array
The following code SHOULD work, but it isn't pulling data. Is there a NEWER/BETTER way to pull data from Active Directory?
PLEASE HELP, here is the code: Dim RecordSet AsNew ADODB.Recordset Dim Command AsNew ADODB.Command Dim arrayUserADInfo AsNew doUserInfo Dim Connection AsNew ADODB.Connection Try With Connection .Provider = "ADsDSOObject" .Open("Active Directory Provider") .Properties("User ID").Value = "ADUserID" .Properties("Password").Value = "ADPassword" .Properties("Encrypt Password").Value = True End With Dim SelectStatement As String = "department, departmentNumber, description, displayName, employeeID, facsimileTelephoneNumber, givenName, lastLogoff, lastLogon, mail, manager, middleName, mobile, pager, photo, SAMAccountName, SN, telephoneNumber, title" Dim FromStatement As String = LDAP://DC=stph,DC=org Dim WhereStatement As String = "objectCategory='Person' AND SAMAccountName='" & strUserName & "'" Command.ActiveConnection = Connection Command.CommandText = "SELECT " & SelectStatement & " FROM " & FromStatement & " WHERE " & WhereStatement RecordSet = Command.Execute If Not RecordSet.EOF Then 'arrayEmployeeInfo.ADsPath = RecordSet.Fields("ADsPath").Value arrayUserADInfo.department = RecordSet.Fields("department").Value arrayUserADInfo.departmentNumber = RecordSet.Fields("departmentNumber").Value arrayUserADInfo.description = RecordSet.Fields("description").Value arrayUserADInfo.displayName = RecordSet.Fields("displayName").Value arrayUserADInfo.employeeID = RecordSet.Fields("employeeID").Value arrayUserADInfo.facsimileTelephoneNumber = RecordSet.Fields("facsimileTelephoneNumber").Value arrayUserADInfo.givenName = RecordSet.Fields("givenName").Value arrayUserADInfo.lastLogoff = RecordSet.Fields("lastLogoff").Value arrayUserADInfo.lastLogon = RecordSet.Fields("lastLogon").Value arrayUserADInfo.mail = RecordSet.Fields("mail").Value arrayUserADInfo.manager = RecordSet.Fields("manager").Value arrayUserADInfo.middleName = RecordSet.Fields("middleName").Value arrayUserADInfo.mobile = RecordSet.Fields("mobile").Value arrayUserADInfo.pager = RecordSet.Fields("pager").Value arrayUserADInfo.photo = RecordSet.Fields("photo").Value arrayUserADInfo.SAMAccountName = RecordSet.Fields("SAMAccountName").Value arrayUserADInfo.SN = RecordSet.Fields("SN").Value arrayUserADInfo.telephoneNumber = RecordSet.Fields("telephoneNumber").Value arrayUserADInfo.title = RecordSet.Fields("title").Value End If Return arrayUserADInfo Catch ex As Exception 'Insert Error Handling Here Finally 'RecordSet.Close() 'Connection.Close() End Try |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Pulling Active Directory info into an array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|