Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript runtime (0x800A0046) Permission denied: 'GetObject'

6 views
Skip to first unread message

Scott Elgram

unread,
Feb 26, 2004, 2:01:01 PM2/26/04
to
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;
'---------Script Begin--------------
strComputer = "Reports"
Set colAccounts = GetObject("WinNT://" & strComputer & ",computer")
Set objUser = colAccounts.Create("user", "NewUser")
objUser.SetPassword "1234"
objUser.Put "Description", "NewUser account"
objUser.SetInfo

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


Torgeir Bakken (MVP)

unread,
Feb 26, 2004, 2:32:36 PM2/26/04
to
Scott Elgram wrote:

> 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


Scott Elgram

unread,
Feb 26, 2004, 5:16:33 PM2/26/04
to
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)

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 (MVP)

unread,
Feb 26, 2004, 6:35:06 PM2/26/04
to
Scott Elgram wrote:

> 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

unread,
Feb 26, 2004, 7:24:56 PM2/26/04
to
Torgeir Bakken,
I actually got it working right after I posted. Thanks for all the
help!

--
-Scott Elgram

"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message

news:403E82AA...@hydro.com...

0 new messages