I need to query active directory, if in organization unit GROUPS exist group with defined name.
Set objGroup = GetObject("LDAP://CN=" & GroupName & ",ou=groups,dc=domain,dc=com")
How to do it?
Thnx for help.
query to active directory
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
query to active directory
I'm not sure I understand. You want to see if a specified group exists within the Groups OU?
The query you have should do just fine. If it doesn't return any object (e,g., IsObject(objGroup) = False), then the group doesn't exist.
The query you have should do just fine. If it doesn't return any object (e,g., IsObject(objGroup) = False), then the group doesn't exist.
query to active directory
trixs -
The structure you are describing looks like th efollowing from your description and LDAP:
LDAP://CN="ou=ou1,ou=Groups,dc=domain,dc=com"
LDAP://CN="ou=ou2,ou=Groups,dc=domain,dc=com"
LDAP://CN="ou=ou1,ou=Groups,dc=domain,dc=com"
|------- OU1
|------- OU2
|--------OU3
To get the "OU" OU within the "Groups" OU you need to do the following query.
Assuming that this will return a collection of "group" type objects you can then enumerate the collection.
You can also get a group directly knowing it's name. Assuming group name is XXX and OU is OU1
Set objGroup = GetObject( "LDAP://cn=XXX,ou=OU1,ou=Groups,dc=domain,dc=com")
This will return the group with "CN" (Canonical Name) of "XXX" that resides in the "OU1" OU within the "Groups" OU.
The ksy is to "point at a container". The container can be an OU, a folder or a container. Then preface the container path with the CN of the item in the container. (CN=itemname). There are other methods but this is most direct and usual.
The choice of names here makes this very hard to explain.
jvierra2008-04-05 11:49:44
The structure you are describing looks like th efollowing from your description and LDAP:
LDAP://CN="ou=ou1,ou=Groups,dc=domain,dc=com"
LDAP://CN="ou=ou2,ou=Groups,dc=domain,dc=com"
LDAP://CN="ou=ou1,ou=Groups,dc=domain,dc=com"
domain.com
|
|------- Groups
|------- OU1
|------- OU2
|--------OU3
To get the "OU" OU within the "Groups" OU you need to do the following query.
Code: Select all
aOUName = "OU1"
Set objGroup = GetObject( "LDAP://ou=" & sOUName & ",ou=Groups,dc=domain,dc=com")
Assuming that this will return a collection of "group" type objects you can then enumerate the collection.
You can also get a group directly knowing it's name. Assuming group name is XXX and OU is OU1
Set objGroup = GetObject( "LDAP://cn=XXX,ou=OU1,ou=Groups,dc=domain,dc=com")
This will return the group with "CN" (Canonical Name) of "XXX" that resides in the "OU1" OU within the "Groups" OU.
The ksy is to "point at a container". The container can be an OU, a folder or a container. Then preface the container path with the CN of the item in the container. (CN=itemname). There are other methods but this is most direct and usual.
The choice of names here makes this very hard to explain.
jvierra2008-04-05 11:49:44