water Posted May 18, 2016 Author Posted May 18, 2016 To get an idea why AD thinks the computer is still a member please run this script: #include <AD.au3> ; Open Connection to the Active Directory _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Global $aProperties[1][2] ; Displays properties for the current computer $aProperties = _AD_GetObjectProperties(@ComputerName & "$") If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_GetObjectProperties encountered a problem. @error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aProperties, "Active Directory Functions - Example 3 - Properties for computer '" & @ComputerName & "'") ; Close Connection to the Active Directory _AD_Close() If the array gets displayed property "distinguishedName" describes where the computer can be found. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 18, 2016 Author Posted May 18, 2016 If you get an error from AD then maybe the local computer still thinks it is joined to a domain. Run this little script and you will see the domain name the computer is joined to. Local $sComputer = @ComputerName Local $oComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & $sComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & $sComputer & "'") If @error Or Not IsObj($oComputer) Then Exit MsgBox(0, "Error", "WMI returned error " & @error) MsgBox(0, "Computer Domain", "Domain is '" & $oComputer.Domain & "'") My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 You know I was thinking it was the computer too- so I started a reformat lol
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 ok this is interesting - I formatted the system - renamed the computer to something unique like Desktop-Tester and rebooted installed latest version of AutoIt and ran script and got _AD_JoinDomain @error=0 @extended = 0 this time around
water Posted May 18, 2016 Author Posted May 18, 2016 Ah, mission accomplished? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 sadly no - when I look in the OU the computer should be in - it's not there I also searched the entire AD Directory for the computer name and it's no where to be found
water Posted May 18, 2016 Author Posted May 18, 2016 Then please run the script as posted in #501. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 I ran script in #501 post and got Function _AD_GetObjectProperties encountered a problem. @error=1, @extended = 0
water Posted May 18, 2016 Author Posted May 18, 2016 Means: The object does not exist. Another try: Modify the last option in _AD_JoinDomain from 2 to 3. This creates the computer and joins it to the domain (hopefully). My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 (edited) I changed the 2 to a 3 and got _AD_JoinDomain @error=4, @extended = 0 I rebooted and still got that error message Edited May 18, 2016 by OrangeCoder
water Posted May 18, 2016 Author Posted May 18, 2016 (edited) OK, now you need to modify the AD UDF. Comment or delete the following (last) line: Func _AD_JoinDomain($sComputer = @ComputerName, $sUserParam = "", $sPasswordParam = "", $sOU = Default, $iFlag = 1, $sNewName = "") If BitAND($iFlag, 2) <> 2 And _AD_ObjectExists($sComputer & "$") = 0 Then Return SetError(1, 0, 0) If $sNewName <> "" And _AD_ObjectExists($sNewName & "$") = 1 Then Return SetError(6, 0, 0) Local $iResult, $iResult2, $sJoinUser, $sJoinPassword, $aTempUser Local $aDomain = StringSplit($sAD_DNSDomain, ",") Local $sDomainName = StringReplace($aDomain[1], "DC=", "") ; Create WMI object Local $oComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\" & $sComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & $sComputer & "'") If @error Or Not IsObj($oComputer) Then Return SetError(3, @error, 0) If $oComputer.Domain = $sDomainName Then Return SetError(4, 0, 0) ; <== make a comment out of this line or delete it Then change the last option in _AD_JoinDomain from 3 to 35. This creates the computer, joins it to the domain and ignores if the computer is already joined to a domain. Edited May 18, 2016 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 ok so I commented out that line in AD.au3 Changed the 3 to 35 and when I ran it got @error = 5, @extended = 1355
water Posted May 18, 2016 Author Posted May 18, 2016 Means: ERROR_NO_SUCH_DOMAIN 1355 (0x54B) The specified domain either does not exist or could not be contacted. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 18, 2016 Author Posted May 18, 2016 "orange.coder" is your username? Is this the name you use to log into Windows. _AD_Open supports 3 formats how to specify the username, _AD_JoinDomain only accepts 2 of them. The dotted format looks a bit weird to me. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 no that's not my login for AD my real username is formatted like that though should I try someone elses login that is not formatted like that ?
water Posted May 18, 2016 Author Posted May 18, 2016 You should replace "orange.coder" with the string you enter when you logon to Windows. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 I did my actually username is firstname.lastname for the script I use the following XXXX\firstname.lastname Do you want me to just use firstname.lastname for the script - dropping the XXX\ ?
water Posted May 18, 2016 Author Posted May 18, 2016 _AD_JoinDomain supports NetBIOSName (domain\user) or user principal name (user@domain). If neither of them works could you test with an account that has no dot (or any other special characters)? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 sure I understood that - I will try with another account that has no dot in the in username
OrangeCoder Posted May 18, 2016 Posted May 18, 2016 ok - update time: -So using a different login that does not have a dot in the username I called AD_JoinDomain with a flag of 35 - and with the line in AD.au3 commented out and got a @error=4,@extended=0
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now