'get path to AD users from web.config file
Dim rootUser As New
DirectoryEntry(System.Configuration.ConfigurationSettings.AppSettings("ADUse
rsPath"))
'Search for user in LDAP root path
Dim ds As New DirectorySearcher(rootUser,
"(&(objectClass=user)(samAccountName=" & UserName & "))")
'return these values only
ds.PropertiesToLoad.Add("mail")
ds.PropertiesToLoad.Add("NativeGuid")
ds.PropertiesToLoad.Add("MemberOf")
ds.PropertiesToLoad.Add("FullName")
'execute the search and return one result
Dim sr As SearchResult = ds.FindOne()
For Each obj As String In sr.Properties("memberOf")
'look up each object
Dim group As New DirectoryEntry("LDAP://" & obj)
'store guid in array
Guid = group.NativeGuid
Next
Hope it helps,
Cheers... Lubos
Reese said:
Does anyone know how to list every group that a user is a member of using
the System.DirectoryServices namespace?