Jump to content

domain


Recommended Posts

You can make a command line script. Something like Join.exe DomainName AdminUserName AdminPassword

;$iFlag JOIN_DOMAIN = 1
;$iFlag ACCT_CREATE = 2
;$iFlag ACCT_DELETE = 4
;$iFlag WIN9X_UPGRADE = 16
;$iFlag DOMAIN_JOIN_IF_JOINED = 32
;$iFlag JOIN_UNSECURE = 64
;$iFlag MACHINE_PASSWORD_PASSED = 128
;$iFlag DEFERRED_SPN_SET = 256/f
;$iFlag INSTALL_INVOCATION = 262144

Func _JoinDomain($sDomain, $sAdUserName, $sAdPassword, $sComputerName = '', $sJoinDomainOU = '', $iFlag = 1)
    If $sComputerName = '' Or $sComputerName = -1 Then $sComputerName = @ComputerName
    ;If $sJoinDomainOU = '' Then $sJoinDomainOU = Chr(0)
    If StringInStr($sAdUserName, '\') = 0 Then $sAdUserName = $sDomain & '\' & $sAdUserName
MsgBox(0, 'Cmd', $sDomain & @CRLF & $sAdUserName & @CRLF & $sAdPassword & @CRLF & $sComputerName & @CRLF & $sJoinDomainOU & @CRLF & $iFlag) 
    $computerObj    = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & _
              $sComputerName & "\root\cimv2:Win32_ComputerSystem.Name='" & _
              $sComputerName & "'")

    $joinDomainResultNumber = $computerObj.JoinDomainOrWorkGroup($sDomain, $sAdPassword, $sAdUserName, $sJoinDomainOU, $iFlag)  
    Select
        Case $joinDomainResultNumber  = 0
            $joinDomainResultText = "The domain join completed successfully."
        Case $joinDomainResultNumber  = 5
            $joinDomainResultText = "The " & $sAdUserName & " account does not have permissions. Most likely this computer was originally joined to the domain with a Account operator account. The account you are using does not have permissions to overwrite the workstation object"
        Case $joinDomainResultNumber  = 86 Or $joinDomainResultNumber = 1326
            $joinDomainResultText = "The username or password you specified is incorrect. Check the username and password as they appear below. If these values are incorrect the image will have to be updated with the current values" 
        Case $joinDomainResultNumber  = 1909
            $joinDomainResultText = "The " & $sAdUserName & " account is locked out. Most likely someone has tried the password incorrectly too many times. The system sometimes will lock the account out if too many simultaneous connection attempts are occuring."
        Case $joinDomainResultNumber  = 2224
            $joinDomainResultText = "The computer account already exists on the domain and could not be overwritten. A workstation object with the same name exists in another OU. You will have to have the existing workstation object deleted."
        Case $joinDomainResultNumber  = 2453
            $joinDomainResultText = "Could not find a domain controller. Please make sure all domain controllers are online and that your network access is functional."
        Case $joinDomainResultNumber  = 2102
            $joinDomainResultText = "The workstation service is not started. Please start this service and try again."
        Case $joinDomainResultNumber  = 2691
            $joinDomainResultText = "This machine is already joined to a domain. If you wish to join this system to another domain or this domain again you will first have to unjoin your existing domain."
    EndSelect   
    Return $joinDomainResultNumber  
EndFunc
This is a UDF to join computer into a domain, only work with WinXP and Win2k3. If you have others OS like Win2k or even WinNT then I suggest to look into Netdom M$ command line and wrapped around AutoIT.

Hopefully this will get you started. You can find more information about $CmdLine in AutoIt help files.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...