Maybe this could be some help?
 
Probably not the most efficient code, but..... it will echo all groups starting with 
Do*
 
set oConnection = CreateObject("ADODB.Connection")
set oCommand = CreateObject("ADODB.Command")
set RS = CreateObject("ADODB.Recordset")
Set oRootDSE = GetObject("LDAP://RootDSE";)
varDomainNC = oRootDSE.Get("defaultNamingContext")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
strQuery = "<LDAP://"; & varDomainNC & 
">;(&(objectCategory=group)(sAMAccountName=Do*));adspath;subtree"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = strQuery
Set RS = oCommand.Execute
While Not RS.EOF
 Set objUser = GetObject(RS.Fields("adspath"))
 WScript.Echo Replace(objUser.Name,"CN=","")
     RS.MoveNext
Wend

 
/MS
 
Disclamer:
This is my very personal opinion

________________________________

From: [EMAIL PROTECTED] on behalf of Creamer, Mark
Sent: Fri 2004-04-30 22:30
To: [EMAIL PROTECTED]
Subject: [ActiveDir] help querying for groups



Hi, can someone help me troubleshoot this script? I'm trying to return all of the 
global groups in the domain whose name starts with RPT. All I'm getting is the error: 
"Provider: Unspecified error"

 

strBase = "<LDAP://dc=my,dc=domain,dc=com>;"

strFilter = "(&(objectCategory=group)(name=RPT*));"

strScope = "Subtree"

 

Set objConn = CreateObject("ADODB.Connection")

objConn.Open "Provider=ADsDSOObject"

Set ObjRS = objConn.Execute(strBase & strFilter & strScope)

objRS.MoveFirst

While Not ObjRS.EOF

     WScript.Echo objRS.Fields(0).Value

     objRS.MoveNext

Wend

 

I'm trying to do this by altering one of the recipes in Robbie Allen's book. Thanks!

 

Mark Creamer

Systems Engineer

Cintas Corporation

Honesty and Integrity in Everything We Do

 

<<winmail.dat>>

Reply via email to