I am wanting to develop a staff directory application, listing all people in the organization, including name, email address, phone number, office location – all of that information. We currently have that in Active Directory, and I’m wanting to develop a simple .Net application to allow people to search and retrieve it. Getting the information appeared simple – there are many examples around using the DirectorySearcher class. I start with
Dim objADAM As DirectoryEntry ' Binding object.
Dim objGroupEntry As DirectoryEntry ' Group Results.
Dim objSearchADAM As DirectorySearcher ' Search object.
Dim objSearchResults As SearchResultCollection ' Results collection.
Dim strPath As String ' Binding path.
objADAM = New DirectoryEntry(strPath)
objADAM.RefreshCache()
objSearchADAM = New DirectorySearcher(objADAM)
objSearchADAM.Filter = "((&(objectClass=user)(objectCategory=person)))"
objSearchADAM.SearchScope = SearchScope.Subtree
objSearchResults = objSearchADAM.FindAll()
I then have a for each loop for each SearchResult Object in the objSearchResults set.
If objSearchResults.Count <> 0 Then
Dim objResult As SearchResult
For Each objResult In objSearchResults
objGroupEntry = objResult.GetDirectoryEntry
I also looked at all of the directory entry properties – the core properties are there, but if I use Active Directory Explorer to browser an actual user object, there are many more attributes listed. Is there some more complex structure to Active Directory that means I need to do more that just the simple FindAll method of a DirectorySearcher?
Thanks…
When you’re using DirectorySearcher, you should specify which exactly properties you want to load (PropertiesToLoad). When i was manipulating big chunks of AD data it was more useful for me to make an instance of DirectoryEntry trought the ADPath. if you do this, you can enlist the properties for yourself.
also, it was pretty handy to use ADSI Edit tool (i think it’s from Microsoft). it allows you to see all possible entries in AD node.
if you need more info, just give a more precise question, i will try my best to answer. spent some time investigating this topic :))