Checking Different sReturn Codes for JoinDomain

email me

* Recommended: add these to a case statement

sReturn = oCmp.JoinDomainOrWorkgroup(strDomain, strPW, strUser, NULL, JOIN_DOMAIN+ACCT_CREATE)
'msgbox "ReturnValue = " & CStr(sReturn)

'successfully joined
if sReturn = 0 then self.close()

'access denied
if sReturn = 5 then msgbox "Access Denied!"

'cannot find network
if sReturn = 53 then msgbox "Network path not found!"

'logon failure
if sReturn = 1326 then msgbox "Invalid credentials!"

'domain contact issue
if sReturn = 1355 then msgbox "Domain cannot be contacted!"

'already joined
if sReturn = 2691 then 
msgbox "Computer already joined!"
self.close()
end if


''''''' Case Statement Example '''''''

'Select Case sReturn

'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 " & sReturn

' Show Status
'WScript.Echo "Join domain status: " & Status

'End Select