Hello, I am trying to create a script that enumerates group membership of one user (stemplateUsr) and adds another user (strUserDN) to those groups.
Here is the pertinent code from my script:
************************************************************
Set adsNameTranslate = CreateObject("NameTranslate")
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, ""
' Set the user name into NameTranslation
adsNameTranslate.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & adsUser
' Get the DN of the user
strUserDN = adsNameTranslate.Get(ADS_NAME_TYPE_1779)
WScript.Echo strUserDN
' Bind to the user object
'This is the new account to be created
Set adsUser = GetObject("LDAP://" & strUserDN)
' Bind to the template user object
'This is the account to copy groups fromo
Set objUser = GetObject("LDAP://" & stemplateUsr)
'Enumerate Groups the template user belongs To
Set objGroup = objUser.memberof
For Each Memberof in objGroup
objGroup.add adsUser.adspath
Next
************************************************************
When I run my script I get "Object not a collection".
Any help is appreciated!!
Scot Lymer
Here is the pertinent code from my script:
************************************************************
Set adsNameTranslate = CreateObject("NameTranslate")
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, ""
' Set the user name into NameTranslation
adsNameTranslate.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & adsUser
' Get the DN of the user
strUserDN = adsNameTranslate.Get(ADS_NAME_TYPE_1779)
WScript.Echo strUserDN
' Bind to the user object
'This is the new account to be created
Set adsUser = GetObject("LDAP://" & strUserDN)
' Bind to the template user object
'This is the account to copy groups fromo
Set objUser = GetObject("LDAP://" & stemplateUsr)
'Enumerate Groups the template user belongs To
Set objGroup = objUser.memberof
For Each Memberof in objGroup
objGroup.add adsUser.adspath
Next
************************************************************
When I run my script I get "Object not a collection".
Any help is appreciated!!
Scot Lymer