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

AD Group Ownership

P: n/a
I am trying to use the following button code to allow a user to enter an
Active Directory account name and then have the system return the specified
user' group memberships and the "ManagedBy" value for each group membership.
Has anyone done this before? As it stands now it will just give back the
group memberships and no "ManagedBy" values. Thanks for all your helpl.
This code is from a button:
CheckedListBox3.Items.Clear()
Dim strDomain As String
Dim rootds As New DirectoryServices.DirectoryEntry("LDAP://rootDSE")
strDomain = rootds.Properties("DefaultNamingContext")(0)
Dim root As New System.DirectoryServices.DirectoryEntry("LDAP://" &_
strDomain)
Dim searcher As New System.DirectoryServices.DirectorySearcher(root)
Dim searchero As New System.DirectoryServices.DirectorySearcher(root)
searcher.Filter = "(&(objectCategory=user)(anr=" & TextBox3.Text & "))"
Dim results As System.DirectoryServices.SearchResultCollection
results = searcher.FindAll()
Dim result As System.DirectoryServices.SearchResult
For Each result In results
Dim User As New System.DirectoryServices.DirectoryEntry(result.Pat h)
Dim group As String
Dim count As Integer = 0
For Each group In (User.Properties("memberof"))
TextBox4.Text = TextBox4.Text & count & " / "
CheckedListBox3.Items.Add(User.Properties("membero f").Item(count))
searchero.Filter = "(&(objectCategory=group)(anr=" &_
User.Properties("memberof").Item(count) & "))"
Dim resulto As System.DirectoryServices.SearchResultCollection
resulto = searchero.FindAll()
Dim item As System.DirectoryServices.SearchResult
For Each item In resulto
Dim owner As New System.DirectoryServices.DirectoryEntry(item.Path)
'TextBox4.Text = TextBox4.Text & count & " / "
CheckedListBox3.Items.Add(owner.Properties.Values)
Next
count = count + 1
Next
User = Nothing
Next result

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>I am trying to use the following button code to allow a user to enter an
Active Directory account name and then have the system return the specified
user' group memberships and the "ManagedBy" value for each group membership.
Has anyone done this before? As it stands now it will just give back the
group memberships and no "ManagedBy" values.


You cannot do this in one step, unfortunately - you cannot query the
user's "memberOf" attribute and in the same search also "join in" the
group's "ManagedBy" attribute (like in a SQL Join).

What you can do (if you REALLY need this) is to enumerate the user's
"memberOf" property, and for each group found, bind to the group and
get it's "managedBy" property. Won't be very fast though! (lots of
costly bind operations).

Marc
Nov 22 '05 #2

P: n/a
>I am trying to use the following button code to allow a user to enter an
Active Directory account name and then have the system return the specified
user' group memberships and the "ManagedBy" value for each group membership.
Has anyone done this before? As it stands now it will just give back the
group memberships and no "ManagedBy" values.


You cannot do this in one step, unfortunately - you cannot query the
user's "memberOf" attribute and in the same search also "join in" the
group's "ManagedBy" attribute (like in a SQL Join).

What you can do (if you REALLY need this) is to enumerate the user's
"memberOf" property, and for each group found, bind to the group and
get it's "managedBy" property. Won't be very fast though! (lots of
costly bind operations).

Marc
Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.