bsharath
asked on
Find all groups that are managed by a user
Hi,
I want to Find all groups that are managed by a user.
Regards
Sharath
I want to Find all groups that are managed by a user.
Regards
Sharath
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
weellio
No results come out...
No results come out...
this works,..
on error resume next
Dim adoConnection, adoCommand, objRootDSE, strDNSDomain, strQuery
Dim adoRecordset, strDN, objGroup, results
' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connec tion")
Set adoCommand = CreateObject("ADODB.Comman d")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnectio n = adoConnection
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE" )
strDNSDomain = objRootDSE.Get("defaultNam ingContext ")
' Search for all groups, return the Distinguished Name of each.
strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectClass=group);dis tinguished Name;subtr ee"
adoCommand.CommandText = strQuery
adoCommand.Properties("Pag e Size") = 100
adoCommand.Properties("Tim eout") = 30
adoCommand.Properties("Cac he Results") = False
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
results = results & "No groups found" & vbcrlf
adoRecordset.Close
adoConnection.Close
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
Wscript.Quit
End If
' Enumerate all groups, bind to each, and document group members.
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("disti nguishedNa me").Value
' Escape any forward slash characters with backslash.
strDN = Replace(strDN, "/", "\/")
Set objGroup = GetObject("LDAP://" & strDN)
strManagedBy = "No_owner"
strManagedBy = objGroup.Get("managedBy")
results = results & objGroup.sAMAccountName _
& vbtab & strManagedBy & vbcrlf
adoRecordset.MoveNext
Loop
wscript.echo results
adoRecordset.Close
' Clean up.
adoConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
on error resume next
Dim adoConnection, adoCommand, objRootDSE, strDNSDomain, strQuery
Dim adoRecordset, strDN, objGroup, results
' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connec
Set adoCommand = CreateObject("ADODB.Comman
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnectio
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE"
strDNSDomain = objRootDSE.Get("defaultNam
' Search for all groups, return the Distinguished Name of each.
strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectClass=group);dis
adoCommand.CommandText = strQuery
adoCommand.Properties("Pag
adoCommand.Properties("Tim
adoCommand.Properties("Cac
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
results = results & "No groups found" & vbcrlf
adoRecordset.Close
adoConnection.Close
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
Wscript.Quit
End If
' Enumerate all groups, bind to each, and document group members.
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("disti
' Escape any forward slash characters with backslash.
strDN = Replace(strDN, "/", "\/")
Set objGroup = GetObject("LDAP://" & strDN)
strManagedBy = "No_owner"
strManagedBy = objGroup.Get("managedBy")
results = results & objGroup.sAMAccountName _
& vbtab & strManagedBy & vbcrlf
adoRecordset.MoveNext
Loop
wscript.echo results
adoRecordset.Close
' Clean up.
adoConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
ASKER
I tried this but there is no error nor output....
Option Explicit
Dim adoConnection, adoCommand, objRootDSE, strDNSDomain, strQuery
Dim adoRecordset, strDN, objGroup, results
' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connec
Set adoCommand = CreateObject("ADODB.Comman
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnectio
' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE"
strDNSDomain = objRootDSE.Get("defaultNam
' Search for all groups, return the Distinguished Name of each.
strQuery = "<LDAP://" & strDNSDomain _
& ">;(objectClass=group);dis
adoCommand.CommandText = strQuery
adoCommand.Properties("Pag
adoCommand.Properties("Tim
adoCommand.Properties("Cac
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
results = results & "No groups found" & vbcrlf
adoRecordset.Close
adoConnection.Close
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing
Wscript.Quit
End If
' Enumerate all groups, bind to each, and document group members.
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("disti
' Escape any forward slash characters with backslash.
strDN = Replace(strDN, "/", "\/")
Set objGroup = GetObject("LDAP://" & strDN)
results = results & objGroup.sAMAccountName _
& vbtab & objGroup.owner & vbcrlf
adoRecordset.MoveNext
Loop
wscript.echo results
adoRecordset.Close
' Clean up.
adoConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing