jdhackett
asked on
Get OU for user from Active Directory properties
Hi
I have code that get AD properties for a user.
For example
But I can't figure out what the code for the OU is. So instead of "telephoneNumber" above, replace it with whatever the code for OU is.
Anyway know what it should be?
I have code that get AD properties for a user.
For example
rowUser.Phone = GetADProperty(resEnt, "telephoneNumber")
rowUser.Department = GetADProperty(resEnt, "Department")
Private Function GetADProperty(ByVal resSearch As SearchResult, ByVal stPropName As String) As String
Dim stProperty As String = ""
If resSearch.Properties.Contains(stPropName) Then
stProperty = resSearch.Properties(stPropName).Item(0)
End If
GetADProperty = stProperty
End Function
But I can't figure out what the code for the OU is. So instead of "telephoneNumber" above, replace it with whatever the code for OU is.
Anyway know what it should be?
OU is used for searching the AD. Not sure what your question is.
ASKER
The part before the sample eturns a full list of all users in AD. I want to get certain properties for each user. In the sample, I'm getting the telephonenumber and department. But I'd also like to get the OU of the user.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.