I have a script that creates two AD security groups based on server names, one a domain local group and the other a global group. After they are created it is supposed to add the global group as a member of the domain local group. We have multiple domains here, and all of the global groups are created in the same domain (we'll call it domain1). The domain local groups are created in the domain where the server is a member (which could be domain2, domain3, etc). I'm told that the domains have full trusts between them.
When I run the script and the server is in domain1, everything works as intended. If I run the script and the server is in any domain other than domain1 I get:
C:\create_groups_test.vbs(88, 2) (null): There is no such object on the server.
The line that is referenced in the error (88) is:
However, the code that creates the groups does function correctly in all cases. That is, regardless of which domain the server is in the groups are created in the correct domains and OUs. It is only the group membership part that fails, and only when the local and global groups are in different domains.
The relevant part of the code is shown below.
If anyone has any idea why this would fail, I'd love to hear suggestions.
When I run the script and the server is in domain1, everything works as intended. If I run the script and the server is in any domain other than domain1 I get:
C:\create_groups_test.vbs(88, 2) (null): There is no such object on the server.
The line that is referenced in the error (88) is:
Code:
objGroupDL.Add(objGroupGG.ADsPath)
However, the code that creates the groups does function correctly in all cases. That is, regardless of which domain the server is in the groups are created in the correct domains and OUs. It is only the group membership part that fails, and only when the local and global groups are in different domains.
The relevant part of the code is shown below.
Code:
arrComputers = Split(strText, vbCrLf)
For Each strComputer in arrComputers
' Create Global group in AD
Set objContainer = GetObject("LDAP://" & strGlobalContainer)
strAdminGlobalName = strComputer & "_Admin_Access_AMR_GG"
Set objGroupGG = objContainer.Create("group", "cn=" & strAdminGlobalName)
objGroupGG.Put "sAMAccountName", strAdminGlobalName
objGroupGG.Put "groupType", ADS_GROUP_TYPE_Global_GROUP Or _
ADS_GROUP_TYPE_SECURITY_ENABLED
objGroupGG.SetInfo
Wscript.Echo objGroupGG.Name & " was successfully created."
' Create Domain Local group in AD
Set objContainer = GetObject("LDAP://" & strDomainLocalContainer & "," & objRootDSE.DistinguishedName)
strAdminDomainLocalName = strComputer & "_Admin_Access_AMR_DL"
Set objGroupDL = objContainer.Create("group", "cn=" & strAdminDomainLocalName)
objGroupDL.Put "sAMAccountName", strAdminDomainLocalName
objGroupDL.Put "groupType", ADS_GROUP_TYPE_LOCAL_GROUP Or _
ADS_GROUP_TYPE_SECURITY_ENABLED
objGroupDL.SetInfo
Wscript.Echo objGroupDL.Name & " was successfully created."
' Make Global group a member of the Domain Local group.
objGroupDL.Add(objGroupGG.ADsPath)
Wscript.Echo objGroupGG.Name & " was successfully added to " & objGroupDL.Name
If anyone has any idea why this would fail, I'd love to hear suggestions.