getting the domain from a user

jat

New member
Joined
Feb 6, 2003
Messages
1
Im using VB.NET to search the active directory and get some information about the users. I can retrieve info about the users such as their path, samaccountname etc. But I want to find out the users DOMAIN. Is there any simple way to do this - Ive attached some cutdown code below


the LDAP path to the directory
Dim strpath As String = Configuration.ConfigurationSettings.AppSettings("LDAPConnectionString")

Obtain the directory entries
objDE = New DirectoryEntry(strpath)
Dim objDS As DirectorySearcher = New DirectorySearcher(objDE)
Dim objChildDE As DirectoryEntry

Obtain the properties for the user entries
Dim props As ResultPropertyCollection
objDS.Filter = "(objectClass=User)"

Find all users
Dim _results As SearchResultCollection = objDS.FindAll()

For Each _result In _results

obtain the properties for the user
props = _result.Properties()

msgbox the info
msgbox props("sAMAccountName")(0).ToString & _
", " & props("displayName")

next



It would be great if there was something like a props("Domain name") :)
ANy ideas?

Cheers
 
Back
Top