By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,550 Members | 908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,550 IT Pros & Developers. It's quick & easy.

VB.NET & Active Directory

P: n/a
Does anyone know how to list every group that a user is a member of using the System.DirectoryServices namespace

I appreciate your help
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
'get path to AD users from web.config file
Dim rootUser As New
DirectoryEntry(System.Configuration.ConfigurationS ettings.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" <an*******@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
Does anyone know how to list every group that a user is a member of using the System.DirectoryServices namespace?
I appreciate your help

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.