I need to take a local group that exists on a computer, and add to it a user that is in a different domain.
I can do this using Local Users and Groups (lusrmgr.msc): I select the Properties for the desired group, click the Add button, enter the user in the form of Domain\User, and click OK. At this point I get prompted to enter the username and password of an account with access rights to the specified domain. I then enter my NT username and password and the user gets added to the local group.
I want to automate this process using VB Script or VB6. I've tried code like the following:
strComputer = "RemoteComputer"
strGroup = "LocalGroup"
strPath = "Domain/User"
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup,group")
Set objUser = GetObject("WinNT://" & strPath & ",user")
objGroup.Add(objUser.ADsPath)
I keep getting a "user not found" error when I try to set objUser. I assume this is because there is no provision to enter a username/password, like I can in Local Users and Groups, which would give the script the rights to browse users in another domain. Anyone know how I can remedy this? I don't care what method is used, although I would prefer something that can be used remotely.
I think there might be a way using LDAP, though I'm not very experienced with it, and don't really follow how you define paths in it (all that "OU=, CN=" stuff).
Thanks
I can do this using Local Users and Groups (lusrmgr.msc): I select the Properties for the desired group, click the Add button, enter the user in the form of Domain\User, and click OK. At this point I get prompted to enter the username and password of an account with access rights to the specified domain. I then enter my NT username and password and the user gets added to the local group.
I want to automate this process using VB Script or VB6. I've tried code like the following:
strComputer = "RemoteComputer"
strGroup = "LocalGroup"
strPath = "Domain/User"
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup,group")
Set objUser = GetObject("WinNT://" & strPath & ",user")
objGroup.Add(objUser.ADsPath)
I keep getting a "user not found" error when I try to set objUser. I assume this is because there is no provision to enter a username/password, like I can in Local Users and Groups, which would give the script the rights to browse users in another domain. Anyone know how I can remedy this? I don't care what method is used, although I would prefer something that can be used remotely.
I think there might be a way using LDAP, though I'm not very experienced with it, and don't really follow how you define paths in it (all that "OU=, CN=" stuff).
Thanks