P-R-W
asked on
VBS script cannot find AD group
Hello,
I have a scripts that shows me all useraccounts that are member of an administrator group. When I ran it, it worked fine. I now have added an extra group: Exchange Organization Administrators but I get the error: There is no such object on the server
This is the code
When I look in AD the group is there.
Thanks for any help
I have a scripts that shows me all useraccounts that are member of an administrator group. When I ran it, it worked fine. I now have added an extra group: Exchange Organization Administrators but I get the error: There is no such object on the server
This is the code
Option Explicit
Dim strMember, strDNSDomain, strContainer
Dim objGroup, objRootDSE
Dim arrMemberOf, arrMemberOf2, arrMemberOf3, arrMemberOf4
Dim strList, strList2, strList3, strList4, arrGroup
' Bind to Active Directory'
strContainer = "cn=Administrators,cn=Builtin, "
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
' Get the Builtin Administrators group
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo
arrMemberOf = objGroup.GetEx("member")
' Loop = For Each .... Next
WScript.Echo "Members of Administrator groups " & vbCrLf
WScript.Echo strContainer & vbCr
WScript.Echo "----------------------------------" & vbCrLf
For Each strMember in arrMemberOf
strMember = Mid(strMember, 4, 330)
arrGroup = Split(strMember, "," )
strList = strList & arrGroup(0) & " " & vbCrLf
Next
Wscript.Echo vbCr & strList
' Get the Domain Administrators group
strContainer = "cn=Domain Admins,cn=Users, "
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo
arrMemberOf2 = objGroup.GetEx("member")
' Loop = For Each .... Next
WScript.Echo strContainer & vbCr
WScript.Echo "----------------------------------" & vbCrLf
For Each strMember in arrMemberOf2
strMember = Mid(strMember, 4, 330)
arrGroup = Split(strMember, "," )
strList2 = strList2 & arrGroup(0) & " " & vbCrLf
Next
Wscript.Echo vbCr & strList2
' Get the Enterprise Administrators group
strContainer = "cn=Enterprise Admins,cn=Users, "
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo
arrMemberOf3 = objGroup.GetEx("member")
' Loop = For Each .... Next
WScript.Echo strContainer & vbCr
WScript.Echo "----------------------------------" & vbCrLf
For Each strMember in arrMemberOf3
strMember = Mid(strMember, 4, 330)
arrGroup = Split(strMember, "," )
strList3 = strList3 & arrGroup(0) & " " & vbCrLf
Next
Wscript.Echo vbCr & strList3
' Get the Exchange Administrators group
strContainer = "cn=Exchange Organization Administrators,cn=Microsoft Exchange Security Groups, "
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo
arrMemberOf4 = objGroup.GetEx("member")
' Loop = For Each .... Next
WScript.Echo strContainer & vbCr
WScript.Echo "----------------------------------" & vbCrLf
For Each strMember in arrMemberOf4
strMember = Mid(strMember, 4, 330)
arrGroup = Split(strMember, "," )
strList4 = strList4 & arrGroup(0) & " " & vbCrLf
Next
Wscript.Echo vbCr & strList4
Wscript.Quit
When I look in AD the group is there.
Thanks for any help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER