Link to home
Start Free TrialLog in
Avatar of jdhackett
jdhackettFlag for Ireland

asked on

Get OU for user from Active Directory properties

Hi
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

Open in new window


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?
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

OU is used for searching the AD. Not sure what your question is.
Avatar of jdhackett

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
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial