Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/NewUser,user")
objGroup.Add(objUser.ADsPath)
objUser.SetInfo
'---------Script End--------------
The problem here is that the computer "Reports" is not the computer
running the script nor is it even in the same domain. When I run it now I
get
Error: Permission denied: 'GetObject'
Code: 800A0046
Is there a way I can pass a username and password or something so it
will work?
--
-Scott Elgram
> Hello,
> I am trying to construct a script that will add local users to a remote
> machine that does not reside in the same domain as the machine running the
> script. Currently I have the following;
> (snip)
> Is there a way I can pass a username and password or something so it
> will work?
Hi
Something like this maybe:
' Insert code to securely retrieve the username and password (sUsername,
sPassword)
Const ADS_SECURE_AUTHENTICATION = 1
sComputer = "some computer name or IP address here"
Set oDSO = GetObject("WinNT:")
Set oComputer = oDSO.OpenDSObject _
("WinNT://" & sComputer, sUsername, sPassword, ADS_SECURE_AUTHENTICATION)
IADsOpenDSObject::OpenDSObject
http://msdn.microsoft.com/library/en-us/adsi/adsi/iadsopendsobject_opendsobject.asp
(note that the constant ADS_SECURE_AUTHENTICATION mentioned in the link above
needs to be explicit defined to 1 in a VBScript)
INFO: User Authentication Issues with ADSI WinNT Provider
http://support.microsoft.com/default.aspx?scid=KB;en-us;218497
An example on how to use OpenDSObject:
Modifying User Cannot Change Password (WinNT Provider)
http://msdn.microsoft.com/library/en-us/adsi/adsi/modifying_user_cannot_change_password_winnt_provider.asp
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
Set oDSO = GetObject("WinNT:")
Set oComputer = oDSO.OpenDSObject("WinNT://" & strComputer, "Aministrator",
"cbn753AD", ADS_SECURE_AUTHENTICATION)
Set objUser = oDSO.Create("user", "Admin2")
objUser.SetPassword "sA2xpWh"
objUser.Put "Description", "Admin2 account"
objUser.SetInfo
Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/Admin2,user")
objGroup.Add(objUser.ADsPath)
objUser.SetInfo
----------End Script--------------
--
-Scott Elgram
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:403E49D4...@hydro.com...
> Torgeir Bakken,
> I have added the code you posted as follows. I am unsure if this is
> correct. When I execute I receive an "unspecified error" on line 5.
> ----------Begin Script--------------
> Const ADS_SECURE_AUTHENTICATION = 1
> strComputer = "Reports"
>
> Set oDSO = GetObject("WinNT:")
> Set oComputer = oDSO.OpenDSObject("WinNT://" & strComputer, "Aministrator",
> "cbn753AD", ADS_SECURE_AUTHENTICATION)
Try this:
Substitute
"Aministrator"
with
strComputer & "\Aministrator"
Also read this one carefully:
http://support.microsoft.com/?kbid=218497
> Set objUser = oDSO.Create("user", "Admin2")
The line above needs to be
Set objUser = oComputer.Create("user", "Admin2")
--
-Scott Elgram
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:403E82AA...@hydro.com...