Hello,
I'm making a treeview to get all the security groups we have in Active Directory.
This is the code what fills my treeview with that data:
But now is the question I want to get a list of all the users in a specified security group from the AD. That's a hard one and i havn't figured that one out. So maybe someone can help me with this?
I tried it with this code:
Only the problem is I don't get a messagebox with a name. For the test I created a security group named: SecurityGroupName
And added some users to it. But when I execute the script down below I won't get a username...... what am I doing wrong???
Or how can I get a list of all users from a security group in Active Directory?
I'm making a treeview to get all the security groups we have in Active Directory.
This is the code what fills my treeview with that data:
VB.NET:
de = New System.DirectoryServices.DirectoryEntry("LDAP://OU=Apps,DC=domain,DC=com")
srch = New System.DirectoryServices.DirectorySearcher(de)
srch.Filter = "(&(objectClass=group))"
OU = TreeView2.Nodes.Add("Groups", "Groups", 0, 0)
For Each result In srch.FindAll()
dir = result.GetDirectoryEntry
users = OU.Nodes.Add(dir.Properties("Name").Value, dir.Properties("Name").Value, 1, 1)
Next
But now is the question I want to get a list of all the users in a specified security group from the AD. That's a hard one and i havn't figured that one out. So maybe someone can help me with this?
I tried it with this code:
Only the problem is I don't get a messagebox with a name. For the test I created a security group named: SecurityGroupName
And added some users to it. But when I execute the script down below I won't get a username...... what am I doing wrong???
Or how can I get a list of all users from a security group in Active Directory?
VB.NET:
de = New System.DirectoryServices.DirectoryEntry("LDAP://CN=SecurityGroupName,OU=Apps,DC=domain,DC=com")
srch = New System.DirectoryServices.DirectorySearcher(de)
srch.Filter = "(&(objectClass=user))"
For Each result In srch.FindAll()
dir = result.GetDirectoryEntry
MsgBox(dir.Properties("Name").Value)
Next