
Oloco
Members-
Posts
3 -
Joined
-
Last visited
Everything posted by Oloco
-
Active Directory UDF - Help & Support (III)
Oloco replied to water's topic in AutoIt General Help and Support
Ok. Thank you very much!- 883 replies
-
- active directory
- ad
-
(and 2 more)
Tagged with:
-
Active Directory UDF - Help & Support (III)
Oloco replied to water's topic in AutoIt General Help and Support
Hi, thanks for your fast reply! I was thinking that it was possible to discover which domains are available to join just asking to DNS server. Do you think that it would be possible? Thank you very much!- 883 replies
-
- active directory
- ad
-
(and 2 more)
Tagged with:
-
Active Directory UDF - Help & Support (III)
Oloco replied to water's topic in AutoIt General Help and Support
Hi guys! I'm new in this community. I really like this languaje, and the forums are awesome. Also, I have to say that the documentation is really good. All of you are doing a very great work. Now I'm working in a proyect for deploying operating systems through SCCM, and I would really like you to help me, if possible. As you know, SCCM provides a way to automatically deploy operating systems in a network. I'm working in a frontend that allows you to choose and save some information for the deployment: - Computer name inout box (done) - Choose between joining domain, or workgroup (done) - In the case of joining domain, which domain, and which OU you want to place the new computer in. (I have done a combobox to search and show all the available ous in the domain, but the comuter needs to be already joined in order to use it, so it is not useful for this case) - Select hard drive and partition (not done, and I think it wil be difficult) -.... Well, most of the interface is built, but I have found some troubles: When the deploy starts, the computer is not a member from AD, so I need to find a way to discover which domains are availables, and if posible, put them all in a combo box, so that I can choose one of them. I know that you can find this kind of information using nslookup, for example (asking to DNS). The main problem is that nslookup is not available in Winpe and I can't find any other way to do this. Also, If it is not possible, I would like to have a input box in order to write the domain name manually, but not all the FQDN. In the case of having a domain named mydomain.local, I need to only write "mydomain" in order to been able to join it (as you can usually do using windows, and if the DNS/DC are correctly configured). I know AD udf and I have worked with it multiple times, but always as an existing domain user. So, the main questions for me are: - Is there a way to automátically discover Domain controllers and domain names using autoit? The computer could ask to DNS in order to find this info. If this would be possible, I would like to populate this information into a combobox and I think I would not need anything more. Also, I think that a domain username and password would be needed, but this it nos problem.. just need to put username and password inputboxes... - In the case that it's not possible, Is there a way to only write manually the main name of the domain (mydomain instead of mydomain.local)? I will put the code that I'm writting in order to have an idea. I know that it's terrible, but I'm not a programmer :-) #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <AD.au3> #include <Array.au3> #Include <WinAPI.au3> #include <GUIComboBox.au3> #Region ### START Koda GUI section ### Form=Form1.kxf $Deploy = GUICreate("Deploy", 746, 441, 199, 151) $COU = GUICtrlCreateCombo("", 136, 128, 569, 25) $Cdisco = GUICtrlCreateCombo("", 136, 208, 169, 25) $Inombreequipo = GUICtrlCreateInput("", 136, 48, 193, 21) $LNombredeequipo = GUICtrlCreateLabel("Computername:", 32, 48, 98, 17) $LOU = GUICtrlCreateLabel("OU:", 16, 128, 106, 17) $LWG = GUICtrlCreateLabel("Workgroup:", 32, 168, 90, 17) $Bok = GUICtrlCreateButton("Ok", 176, 352, 75, 25) $BCancelar = GUICtrlCreateButton("Cancel", 280, 352, 75, 25) $Ginstala = GUICtrlCreateGroup("", 136, 248, 65, 57, -1, $WS_EX_TRANSPARENT) GUICtrlCreateGroup("", -99, -99, 1, 1) $Rinstalasi = GUICtrlCreateRadio("Sí", 144, 256, 41, 17) GUICtrlSetResizing(-1, $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $Rinstalano = GUICtrlCreateRadio("No", 144, 280, 41, 17) $Ldisco = GUICtrlCreateLabel("Partition:", 32, 208, 89, 17) $Linstala = GUICtrlCreateLabel("Install apps:", 16, 272, 106, 17) $LMeterendominio = GUICtrlCreateLabel("Join Domain:", 40, 88, 91, 17) $Gdominio = GUICtrlCreateGroup("", 144, 80, 105, 33) $RMeterendominiosi = GUICtrlCreateRadio("Yes", 152, 88, 41, 17, BitOR($GUI_SS_DEFAULT_RADIO,$BS_CENTER,$BS_VCENTER)) GUICtrlSetState(-1, $GUI_CHECKED) $RMeterendominiono = GUICtrlCreateRadio("No", 200, 88, 41, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Bparticion = GUICtrlCreateButton("Manually partition", 336, 208, 75, 25) $IWG = GUICtrlCreateInput("", 136, 168, 201, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetState ($RMeterendominiosi, $GUI_CHECKED) GUICtrlSetState($COU, $GUI_ENABLE) GUICtrlSetState($IWG, $GUI_DISABLE) GUICtrlSetState ($Rinstalasi, $GUI_CHECKED) _getad() _disks() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $RMeterendominiosi If GUICtrlRead ($RMeterendominiosi) = $GUI_CHECKED Then GUICtrlSetState($COU, $GUI_ENABLE) GUICtrlSetState($IWG, $GUI_DISABLE) endif case $RMeterendominiono If GUICtrlRead ($RMeterendominiono) = $GUI_CHECKED Then GUICtrlSetState($COU, $GUI_DISABLE) GUICtrlSetState($IWG, $GUI_ENABLE) endif case $BCancelar _cancelar() case $Bok _ok() EndSwitch WEnd func _getad() _AD_Open() ;Global $aOUs = _AD_GetAllOUs("","",2) Global $aOUs = _AD_GetAllOUs() ; Global $aOUs = _AD_GetAllOUs() ---> muestra sólo ou's If @error > 0 Then msgbox(64, "Active Directory Functions", "No OUs could be found") EndIf _AD_Close() Global $sOU, $iCount For $iCount = 1 To $aOUs[0][0] If StringInStr($aOUs[$iCount][0], "\") > 0 Then $sOU = "OU=" & StringReplace($aOUs[$iCount - 1][0], "\", ",OU=") & "," & $sAD_DNSDomain ExitLoop EndIf Next For $i=1 to Ubound($aOUs)-1 GUICtrlSetData($COU, $aOUs[$i][0]) ;GUICtrlSetData($COU, $aOUs[$i][0]) ; --> Para ver los nombres de las OUs ;GUICtrlSetData($COU, $aOUs[$i][1]) ; --> Para ver los nombres "bonitos" Next ;_ArrayDisplay($aOUs, "aOUs display") endfunc func _disks() $aArray = DriveGetDrive("FIXED") $dvalue = "c:" $iPosition=_ArraySearch($aArray, $dvalue, 0, 0, 0, 1, 1, 0) if $iPosition = "-1" then For $i=1 To $aArray[0] $maArray = StringUpper($aArray[$i]) GUICtrlSetData($Cdisco, $maArray) next _GUICtrlComboBox_SetCurSel($Cdisco, $aArray[1]) else For $i=1 To $aArray[0] $maArray = StringUpper($aArray[$i]) GUICtrlSetData($Cdisco, $maArray) next _GUICtrlComboBox_SetCurSel($Cdisco, $iPosition -1) endif endfunc func _ok() RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "OSDComputerName") RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Instapps") RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "OSDJoinWorkgroupName") RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "MachineObjectOU") EnvUpdate() ;Nombre de equipo $vInombreequipo = GUICtrlRead($Inombreequipo) If StringLen(GuiCtrlRead($vInombreequipo)) < 0 Then MsgBox($MB_SYSTEMMODAL, "ERROR", "Debes escribir un nombre de equipo.", 10) return else $result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "OSDComputerName", "REG_SZ", $vInombreequipo) If $result = 1 Then else MsgBox($MB_SYSTEMMODAL, "ERROR", "No se ha podido declarar la variable del sistema OSDComputerName.", 10) endif endif ; Se instalan aplicaciones If GUICtrlRead ($Rinstalasi) = $GUI_CHECKED Then $vInstapps = "si" $result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Instapps", "REG_SZ", "si") If $result = 1 Then else MsgBox($MB_SYSTEMMODAL, "ERROR", "No se ha podido declarar la variable del sistema Instapps.", 10) endif endif ;Meter en dominio If GUICtrlRead ($RMeterendominiono) = $GUI_CHECKED Then $grupodetrabajo = GUICtrlRead ($IWG) If StringLen(GuiCtrlRead($grupodetrabajo)) < 0 Then MsgBox($MB_SYSTEMMODAL, "ERROR", "Debes escribir un Grupo de Trabajo.", 10) return endif $result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "OSDJoinWorkgroupName", "REG_SZ", $grupodetrabajo) If $result = 1 Then else MsgBox($MB_SYSTEMMODAL, "ERROR", "No se ha podido declarar la variable del sistema OSDJoinWorkgroupName.", 10) endif Else $vNombredeDOminio = GUICtrlRead ($COU) $result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "MachineObjectOU", "REG_SZ", $vNombredeDOminio) If $result = 1 Then else MsgBox($MB_SYSTEMMODAL, "ERROR", "No se ha podido declarar la variable del sistema MachineObjectOU.", 10) endif endif ;Elegir particion $vCdisco = GUICtrlRead($Cdisco) ;Grabamos y salimos $log = "_log.txt" FileOpen ($log, 0) if isdeclared ("vNombredeDOminio") then FileWrite ($log, "MachineObjectOU: " & $vNombredeDOminio & @CRLF) else FileWrite ($log, "OSDJoinWorkgroupName: " & $grupodetrabajo & @CRLF) endif FileWrite ($log, "OSDComputerName: " & $vInombreequipo & @CRLF) if isdeclared ("vInstapps") then FileWrite ($log, "Instapps: " & "si" & @CRLF) else FileWrite ($log, "Instapps: " & "no" & @CRLF) endif FileWrite ($log, "" & @CRLF) FileWrite ($log, "" & @CRLF) FileWrite ($log, "" & @CRLF) FileClose ($log) EnvUpdate() exit endfunc func _Cancelar() exit endfunc ;VARIABLES ;MachineObjectOU = "OU=Workstations, dc=contoso, dc=com" ;OSDComputerName ;Instapps ;OSDJoinWorkgroupName Thanks in advance, and please, let me know any doubt you could have. I know that my english is really bad... Regards- 883 replies
-
- active directory
- ad
-
(and 2 more)
Tagged with: