Re: problem ading local user
From: Scott Elgram (SElgram_at_verifpoint.com)
Date: 03/19/04
- Next message: Mike Brannigan [MSFT]: "Re: Can windows handle this simple task? - Create user account thru command line-"
- Previous message: Ruby Tuesdays: "Can windows handle this simple task? - Create user account thru command line-"
- In reply to: Stivie S.: "RE: problem ading local user"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 19 Mar 2004 08:57:49 -0800
Stivie,
Thanks for that. I changed it around but I still get the same error.
"c:\AddLocalUser.vbs(10, 1) (null): A specified logon session does not
exist. It may already have been terminated."
Here is an updated version with the changes you suggested.
---------Begin Script---------
Const ADS_SECURE_AUTHENTICATION = 1
strComputer = "Reports"
strUser = "Administrator"
strPassword = "4321"
Set oDSO = GetObject("WinNT:")
Set oComputer = oDSO.OpenDSObject("WinNT://" & strComputer & ",computer",
strUser, strPassword, ADS_SECURE_AUTHENTICATION)
Set objUser = oComputer.Create("user", "testAccount")
objUser.SetPassword "1234"
objUser.Put "FullName", "some full name"
ObjUser.Put "Description", "Script generated test account"
objUser.SetInfo
Set objGroup = GetObject("WinNT://" & strComputer & "/Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/testAccount,user")
objGroup.Add(objUser.ADsPath)
objUser.SetInfo
---------End Script---------
I am trying to execute the script through MS SQL 7 using "EXEC
master..xp_CmdShell 'CScript c:\AddLocalUser.vbs'" if that makes a
difference. I have seen some documentation about executing scripts this
way.
"When xp_cmdshell is invoked by a user who is a member of the sysadmin
fixed server role, xp_cmdshell will be executed under the security context
in which the SQL Server service is running. When the user is not a member of
the sysadmin group, xp_cmdshell will impersonate the SQL Server Agent proxy
account, which is specified using xp_sqlagent_proxy_account. If the proxy
account is not available, xp_cmdshell will fail. This is true only for
Microsoft® Windows NT® 4.0 and Windows 2000. On Windows 9.x, there is no
impersonation and xp_cmdshell is always executed under the security context
of the Windows 9.x user who started SQL Server."
I am hoping that by specifying the account in the script I can work
around this.
--
-Scott Elgram
"Stivie S." <stefan.suesser@computacenter.com> wrote in message
news:B46E317F-29A8-43E3-AEAC-10417F5DF1B7@microsoft.com...
> Hi Scott,
>
> the connection string is a litte different that yours when you want to
connect to a remote machine (not domain). When connecting to a remote
machine, you have to specify the type of object you connect to. Please have
a look at this sample code and modify your own script accordingly:
>
> Const ADS_SECURE_AUTHENTICATION = 1
>
> strComputer = "Server_Name"
> strUser = "Admin_Name"
> strPassword = "Admin_Password"
>
> Set oDSO = GetObject("WinNT:")
> Set oComputer = oDSO.OpenDSObject("WinNT://" & strComputer & ",computer",
strUser, strPassword, ADS_SECURE_AUTHENTICATION)
>
> Set objUser = oComputer.Create("user", "MyTestAccount")
> objUser.SetPassword "1234"
> objUser.Put "FullName", "some full name"
> ObjUser.Put "Description", "A new Account"
> objUser.SetInfo
- Next message: Mike Brannigan [MSFT]: "Re: Can windows handle this simple task? - Create user account thru command line-"
- Previous message: Ruby Tuesdays: "Can windows handle this simple task? - Create user account thru command line-"
- In reply to: Stivie S.: "RE: problem ading local user"
- Messages sorted by: [ date ] [ thread ]