snapo84 Posted January 30, 2017 Share Posted January 30, 2017 Hello Everyone, I have created a small GUI for our WinPE installer which should login to Active Directory and check all groups from the specific user, if the user is in the group it should exit with 0. Currently if i test it on a computer that is domain joined it works without any issue. If i test it on a computer that is not domain joined, it also works. But if i try the same thing on a computer that is booted in WinPE10 and i try to execute it the _AD_Open function fails.... with some strange exit code... There is always the same error: 8 - OpenDSObject method failed. @extended set to error code received from the OpenDSObject method. @error = 4 , @extended = -2147221020 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;***************************************** ;SCCM_Deployment.au3 by Mike ;Created with ISN AutoIt Studio v. 1.03 ;***************************************** Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> ;~ #include <WindowsConstants.au3> #include <GuiButton.au3> #include <MsgBoxConstants.au3> ;~ #include <WinAPIFiles.au3> #include <array.au3> #include <Includes\AD.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Global $RegSource = "HKEY_LOCAL_MACHINE\SOFTWARE\ImageW10" Global $SUserId, $SDNSDomain, $SHostServer, $SConfiguration, $SPassword, $SUserId, $aTEMP, $SInGroup, $Password Global $LoginCounter = "5" $SUserId = "e-mail@company.com" $SDNSDomain = "DC=eu,DC=company,DC=local" $SHostServer = "eu.company.local" $SConfiguration = "CN=Configuration,DC=company,DC=local" $SInGroup = "CN=UserGroupSpecified,OU=Groups,OU=ZRH,OU=CH,DC=eu,DC=company,DC=local" $SPassword = "asdfasdfasdfasd" ;~ ConsoleWrite("CityCode Constant: " & $CCV_CityCode & @CRLF) ;~ For Debug only ;~ ConsoleWrite("CityCode Dynamic: " & $CV_CityCode & @CRLF) ;~ For Debug only $ini = "workplaceframework.ini" $Section2 = "keyboardsettings" Global $sect2 $keyboardsettingsArray = IniReadSection($ini, $Section2) ;~ Read the Inifile Global $keyboardsettings = "Section " & $sect2 & @CRLF For $i = 1 To $keyboardsettingsArray[0][0] $keyboardsettings &= $keyboardsettingsArray[$i][0] & " = " & $keyboardsettingsArray[$i][1] & @CRLF Next ;~ Create an Array from the Keyboardlist Global $allkeyboardlanguages = " " Global Const $arrayLenght = UBound($keyboardsettingsArray, 1) For $i = 1 To $arrayLenght - 1 ;~ ConsoleWrite("keyboard: " & $i & @CRLF) ;~ For Debug only ;~ ConsoleWrite("keyboard2: " & $keyboardsettingsArray[$i][1] & @CRLF) ;~ For Debug only $allkeyboardlanguages = $allkeyboardlanguages & $keyboardsettingsArray[$i][0] & " - " & $keyboardsettingsArray[$i][1] & " |" Next Func _changeKeyboard() Local $keyboard_set = IniRead($ini, "keyboardsettings", GUICtrlRead($Handle_Keyboard), "0409:00000409") ;~ 0409 is default if entry does not exist in the ini configuration file $keyboard_set = StringRight(GUICtrlRead($Handle_Keyboard), 13) ;~ RegWrite($RegSource, "CV_Secret", "REG_SZ", "TheTopSecureSecretFromSCCM") _ReadAllRegKeyAgain() EndFunc ;==>_changeKeyboard Func _exitProgram() Exit EndFunc ;==>_exitProgram Func _shutdownNow() Global $shutdown = "x:\windows\system32\wpeutil.exe shutdown" Run(@ComSpec & " /c " & $shutdown, "", @SW_HIDE) EndFunc ;==>_shutdownNow Func _countWrongLogins() $LoginCounter = $LoginCounter -1 If $LoginCounter = 0 Then ;~ _shutdownNow() MsgBox($MB_SYSTEMMODAL, "Title", "Shutdown Debug", 10) _exitProgram() EndIf EndFunc ;==>_countWrongLogins Func _correctLogin() RegWrite($RegSource, "CV_Keyboard", "REG_SZ", $keyboard_set) EndFunc ;==>_correctLogin Func _clickLogin() $SUserId = GUICtrlRead($HandleUserId) $SPassword = GUICtrlRead($HandlePassword) ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "Before Login", 20) _AD_Open($SUserId, $SPassword, $SDNSDomain, $SHostServer, $SConfiguration) ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "After Login", 20) _checkGroupAD() ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "After Group Check", 20) _AD_Close() ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "After Close", 20) $HandleLoginCounter = GUICtrlCreateLabel($LoginCounter,56,326,9,15,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") EndFunc ;==>_clickLogin Func _checkGroupAD() ; Get the Fully Qualified Domain Name (FQDN) for the current user ; $sFQDN_User = _AD_SamAccountNameToFQDN() $sFQDN_User = _AD_SamAccountNameToFQDN() ; Check the group membership of the specified user for the specified group $iResult = _AD_IsMemberOf($SInGroup, $sFQDN_User) If $iResult = 1 Then ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "User is in Group", 20) MsgBox($MB_SYSTEMMODAL, "Success", "User is in Group", 20) Else ;~ MsgBox($MB_SYSTEMMODAL, "Title", $SUserId & $SPassword & "Error occured", 20) MsgBox($MB_SYSTEMMODAL, "Error", "Wrong Username/PW or no Network connectivity", 20) _countWrongLogins() EndIf EndFunc ;==>_checkGroupAD #include "Forms\AD_Auth.isf" ;~ Initiates our GUI References and settings, dont put this at the beginning Func main() Opt("GUIOnEventMode", 1) GUISetState(@SW_SHOW, $Image_Customization) ; will display our dialog window ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>main main() AD_Auth.isf is just the GUI, but i also attach it here expandcollapse popup; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> #include <EditConstants.au3> #include <ComboConstants.au3> $Image_Customization = GUICreate("company Customization Tool",609,455,-1,-1,$WS_POPUP,$WS_EX_TOPMOST) GUISetBkColor(0xFFFFFF,$Image_Customization) GUISetOnEvent($GUI_EVENT_CLOSE, "_exitProgram", $Image_Customization) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_exitProgram", $Image_Customization) GUISetOnEvent($GUI_EVENT_RESTORE, "_exitProgram", $Image_Customization) GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_exitProgram", $Image_Customization) GUICtrlCreateLabel("Active Directory Username",56,181,235,27,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("Active Directory Password",56,235,235,34,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") GUICtrlSetBkColor(-1,"-2") $HandleUserId = GUICtrlCreateInput($SUserId,328,176,247,20,$ES_CENTER,$WS_EX_CLIENTEDGE) $HandlePassword = GUICtrlCreateInput("",328,230,247,20,BitOr($ES_CENTER,$ES_PASSWORD),$WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Change Keyboard for this Login",53,129,235,24,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") GUICtrlSetBkColor(-1,"-2") $HandleLoginCounter = GUICtrlCreateLabel($LoginCounter,56,326,9,15,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("Password try's left...",93,326,174,21,-1,-1) GUICtrlSetFont(-1,8,700,0,"MS Sans Serif") GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("company Workplace Framework",0,10,646,82,$SS_CENTER,-1) GUICtrlSetFont(-1,25,700,0,"Microsoft Sans Serif") GUICtrlSetBkColor(-1,"-2") GUICtrlCreateButton("Login",353,311,200,30,-1,-1) GUICtrlSetOnEvent(-1,"_clickLogin") $Handle_Keyboard = GUICtrlCreateCombo("",328,129,246,24,-1,-1) GUICtrlSetData(-1,$allkeyboardlanguages) GUICtrlSetOnEvent(-1,"_changeKeyboard") #cs [gui] Handle_deklaration=default Handle_deklaration_const=false title=company Customization Tool breite=609 hoehe=455 style=$WS_POPUP exstyle=$WS_EX_TOPMOST bgcolour=0xFFFFFF bgimage=none handle=Image_Customization parent= code= codebeforegui= xpos=-1 ypos=-1 center_gui=true title_textmode=normal isf_include_once=false only_controls_in_isf=false const_modus=default gui_event_close=_exitProgram gui_event_minimize=_exitProgram gui_event_restore=_exitProgram gui_event_maximize=_exitProgram gui_event_mousemove= gui_event_primarydown= gui_event_primaryup= gui_event_secoundarydown= gui_event_secoundaryup= gui_event_resized= gui_event_dropped= [0x00101D5E] handle=406 locked=0 resize= code= type=label x=53 y=129 width=235 height=24 text=Change Keyboard for this Login tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour=-2 font=MS Sans Serif fontsize=8 fontstyle=700 fontattribute=0 id= func= bgimage= tabpage=-1 iconindex= textmode=text order=8 [0x000A1D5A] handle=407 locked=0 resize= code= type=button x=353 y=311 width=200 height=30 text=Login tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour= font=MS Sans Serif fontsize=8 fontstyle=400 fontattribute=0 id= func=_clickLogin bgimage= order=30 tabpage=-1 iconindex= textmode=text [0x000A1D56] handle=408 locked=0 resize= code= type=label x=0 y=10 width=646 height=82 text=company Workplace Framework tooltip= state=$GUI_SHOW+$GUI_ENABLE style=$SS_CENTER exstyle= textcolour=0x000000 bgcolour=-2 font=Microsoft Sans Serif fontsize=25 fontstyle=700 fontattribute=0 id= func= bgimage= order=30 tabpage=-1 iconindex= textmode=text [0x00021D4E] handle=409 locked=0 resize= code= type=combo x=328 y=129 width=246 height=24 text=$allkeyboardlanguages tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour= font=MS Sans Serif fontsize=8 fontstyle=400 fontattribute=0 id=Handle_Keyboard func=_changeKeyboard bgimage= tabpage=-1 iconindex= textmode=func order=33 [0x00021D3E] handle=410 locked=0 resize= code= type=label x=56 y=181 width=235 height=27 text=Active Directory Username tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour=-2 font=MS Sans Serif fontsize=8 fontstyle=700 fontattribute=0 id= func= bgimage= tabpage=-1 iconindex= textmode=text order=5 [0x00021D32] handle=411 locked=0 resize= code= type=label x=56 y=235 width=235 height=34 text=Active Directory Password tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour=-2 font=MS Sans Serif fontsize=8 fontstyle=700 fontattribute=0 id= func= bgimage= tabpage=-1 iconindex= textmode=text order=6 [0x00021D36] handle=412 locked=0 resize= code= type=input x=328 y=176 width=247 height=20 text=$SUserId tooltip= state=$GUI_SHOW+$GUI_ENABLE style=$ES_CENTER exstyle=$WS_EX_CLIENTEDGE textcolour=0x000000 bgcolour= font=MS Sans Serif fontsize=8 fontstyle=400 fontattribute=0 id=HandleUserId func= bgimage= order=7 tabpage=-1 iconindex= textmode=func [0x00021D2A] handle=413 locked=0 resize= code= type=input x=328 y=230 width=247 height=20 text= tooltip= state=$GUI_SHOW+$GUI_ENABLE style=$ES_CENTER+$ES_PASSWORD exstyle=$WS_EX_CLIENTEDGE textcolour=0x000000 bgcolour= font=MS Sans Serif fontsize=8 fontstyle=400 fontattribute=0 id=HandlePassword func= bgimage= tabpage=-1 iconindex= textmode=text order=8 [0x00021D28] handle=414 locked=0 resize= code= type=label x=56 y=326 width=9 height=15 text=$LoginCounter tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour=-2 font=MS Sans Serif fontsize=8 fontstyle=700 fontattribute=0 id=HandleLoginCounter func= bgimage= order=9 tabpage=-1 iconindex= textmode=func [0x00021D3C] handle=415 locked=0 resize= code= type=label x=93 y=326 width=174 height=21 text=Password try's left... tooltip= state=$GUI_SHOW+$GUI_ENABLE style= exstyle= textcolour=0x000000 bgcolour=-2 font=MS Sans Serif fontsize=8 fontstyle=700 fontattribute=0 id= func= bgimage= order=10 tabpage=-1 iconindex= textmode=text [tab] code=; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ;[BREAK]#include <StaticConstants.au3>[BREAK]#include <GUIConstantsEx.au3>[BREAK]#include <WindowsConstants.au3>[BREAK]#Include <GuiButton.au3>[BREAK]#include <EditConstants.au3>[BREAK]#include <ComboConstants.au3>[BREAK][BREAK]$Image_Customization = GUICreate("company Customization Tool",609,455,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)[BREAK]GUISetBkColor(0xFFFFFF,$Image_Customization)[BREAK]GUISetOnEvent($GUI_EVENT_CLOSE, "_exitProgram", $Image_Customization)[BREAK]GUISetOnEvent($GUI_EVENT_MINIMIZE, "_exitProgram", $Image_Customization)[BREAK]GUISetOnEvent($GUI_EVENT_RESTORE, "_exitProgram", $Image_Customization)[BREAK]GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_exitProgram", $Image_Customization)[BREAK]GUICtrlCreateLabel("Active Directory Username",56,181,235,27,-1,-1)[BREAK]GUICtrlSetFont(-1,8,700,0,"MS Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]GUICtrlCreateLabel("Active Directory Password",56,235,235,34,-1,-1)[BREAK]GUICtrlSetFont(-1,8,700,0,"MS Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]$HandleUserId = GUICtrlCreateInput($SUserId,328,176,247,20,$ES_CENTER,$WS_EX_CLIENTEDGE)[BREAK]$HandlePassword = GUICtrlCreateInput("",328,230,247,20,BitOr($ES_CENTER,$ES_PASSWORD),$WS_EX_CLIENTEDGE)[BREAK]GUICtrlCreateLabel("Change Keyboard for this Login",53,129,235,24,-1,-1)[BREAK]GUICtrlSetFont(-1,8,700,0,"MS Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]$HandleLoginCounter = GUICtrlCreateLabel($LoginCounter,56,326,9,15,-1,-1)[BREAK]GUICtrlSetFont(-1,8,700,0,"MS Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]GUICtrlCreateLabel("Password try's left...",93,326,174,21,-1,-1)[BREAK]GUICtrlSetFont(-1,8,700,0,"MS Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]GUICtrlCreateLabel("company Workplace Framework",16,12,646,82,$SS_CENTER,-1)[BREAK]GUICtrlSetFont(-1,25,700,0,"Microsoft Sans Serif")[BREAK]GUICtrlSetBkColor(-1,"-2")[BREAK]GUICtrlCreateButton("Login",353,311,200,30,-1,-1)[BREAK]GUICtrlSetOnEvent(-1,"_clickLogin")[BREAK]$Handle_Keyboard = GUICtrlCreateCombo("",328,129,246,24,-1,-1)[BREAK]GUICtrlSetData(-1,$allkeyboardlanguages)[BREAK]GUICtrlSetOnEvent(-1,"_changeKeyboard") #ce Link to comment Share on other sites More sharing options...
snapo84 Posted January 30, 2017 Author Share Posted January 30, 2017 4 - Creation of the RootDSE object failed. @extended returns the error code received by the COM error handler. its error 4 not 8 am sorry... Link to comment Share on other sites More sharing options...
water Posted January 30, 2017 Share Posted January 30, 2017 The ADSI plugin needs to be installed. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
snapo84 Posted January 30, 2017 Author Share Posted January 30, 2017 Thanks a lot, will try it. Link to comment Share on other sites More sharing options...
water Posted January 30, 2017 Share Posted January 30, 2017 Details can be found here: My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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