Hi,
First let me start by saying I'm no vbscripter but I've been doing some
playing around and I'm trying to write a small vbscript that I can
execute with cscript to create a local user on a remote Standalone
machine.
I started by creating a simple script that allows me to enter the
computer name to create the account on along with the username and
password of the new user account that will be created. I was able to run
this script on my local machine without problems and I was also able to
supply a different computer and successfully created the account after
authenticating myself with net use \\remotepc /user:<Administrator>
<Password>
------
strComputer = InputBox("Enter Computer Name: ", "Computer Name")
strUserName = InputBox("Enter UserName: ", "User Information")
strPassword = InputBox("Enter Password: ", "Password")
Set Accounts = GetObject("WinNT://" & strComputer & ",computer")
Set objUser = Accounts.Create("user", strUserName)
objUser.SetPassword strPassword
objUser.Put "PasswordExpired", 1
objuser.Fullname = "Test User"
objuser.description = "Test Description"
objUser.SetInfo
------
So now my problem, after two days of reading, I haven't really been able
to figure out how I can avoid the net use procedure and have the script
authenticate and create the user on a remote standalone box. I've read
that it's farily easy to authenticate a user on Active Directory using
the LDAP Provider, I've been trying to do the same thing using the WinNT
provider. As you can see from some good I pieced together with sames on
the net.
As I said before, I'm not vbscripter and I'm not sure if I'm even going
in the right direction, but I hope that someone could give me some
suggestions or point me to a sample script that can authenticate as a
user on a remote box that isn't on the domain to perform administrative
tasks.
Thanks in Advance!
---
strComputer = InputBox("Please enter Computer Name: ", "Computer Name")
strUserName = InputBox("Please enter UserName: ", "User Information")
strPassword = InputBox("Please enter Password: ", "Password")
on error resume next
strADsPath = ("WinNT://" & strComputer)
if (not strADsPath= "") then
' bind to the ADSI object and authenticate Username and password
Dim oADsObject
Set oADsObject = GetObject(strADsPath)
WScript.Echo "Authenticating"
Dim strADsNamespace
Dim oADsNamespace
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)
Set oADsObject = oADsNamespace.OpenDSObject(strADsPath & "/" &
strUserName, strUserName, strPassword, 1)
' we're only bound if err.number = 0
if not (Err.number = 0) then
WScript.Echo "Failed to bind to object" ' & strADsPath
WScript.Echo err.description
WScript.Echo "Error number is " & err.number
else
WScript.Echo "USER AUTHENTICATED!"
WScript.Echo "Currently viewing object at " & oADsObject.ADsPath
WScript.Echo "Class is " & oADsObject.Class
end if
end if
---