[Samba] Anybody have issues joining machines to a S4 AD domain using VBS

Damien Dye damien.dye at sondrel.com
Tue Mar 4 10:30:17 MST 2014


All


got an issue I have a VBS that should join machines to the domain but it's
not working get access denied instantly

anybody got any working scripts they would like to share with me.


btw my script that doesn't work is below




' Join a Computer to a Domain


Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144


strDomain = "xxxx.com"
strPassword = "xxxx"
strUser = "Joiner"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Join Computer to domain
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
& _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, NULL, _
JOIN_DOMAIN + ACCT_CREATE)



Select Case ReturnValue

Case 0 Status = "Success"
Case 2 Status = "Missing OU"
Case 5 Status = "Access denied"
Case 53 Status = "Network path not found"
Case 87 Status = "Parameter incorrect"
Case 1326 Status = "Logon failure, user or pass"
Case 1355 Status = "Domain can not be contacted"
Case 1909 Status = "User account locked out"
Case 2224 Status = "Computer Account already exists"
Case 2691 Status = "Already joined"
Case Else Status = "UNKNOWN ERROR " & ReturnValue


End Select
' Show Status
x=MsgBox( "Join domain status: " & Status, 0, "Domain join results")


--

Damien Dye
 IT Manager
 *Sondrel Ltd*
 Sondrel House, Theale Lakes Business Park
Moulden Way, Sulhamstead, Berkshire, RG7 4GB, UK

Tel: +44(0)118 9838 550
www.sondrel.com

 [image: Sondrel] <http://www.sondrel.com/>

This e-mail and any attachments may be confidential or legally privileged.
If you are not the intended recipient, you should destroy the e-mail
message and any attachments, and inform us of the erroneous delivery by
return e-mail. You are prohibited from retaining, distributing, disclosing
or using any information contained herein. Internet communications cannot
be guaranteed to be timely, secure, error or virus-free. Sondrel Ltd and
the sender do not accept liability for any errors or omissions, nor do we
accept liability for the content of this email, or for the consequences of
any actions taken on the basis of the information provided, unless that
information is consequently confirmed in writing under the personal
signature of a duly authorised officer of Sondrel Ltd.

This email is sent on behalf of Sondrel Ltd registered in England with
number 4491953, registered office Sondrel House, Theale Lakes Business
Park, Moulden Way, Sulhamstead, Berkshire, RG7 4GB, UK.


More information about the samba mailing list