Jump to content

ECHAIGNE

Active Members
  • Posts

    55
  • Joined

  • Last visited

Profile Information

  • Location
    France

ECHAIGNE's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. No, it's not work but If Not @error And $avUser <> 0 Then Or If Not @error And isarray($avUser) Then seems work ==> try this Local $test For $i = 0 To 2 $test = Test($i) If Not @error And IsArray($test) Then ConsoleWrite("Test Array OK ==> " & $test[2] & @LF) Else ConsoleWrite("Error" & @LF) EndIf $test = Test($i) If Not @error And $test <> 0 Then ConsoleWrite("Test <> 0 OK ==> " & $test[2] & @LF) Else ConsoleWrite("Error" & @LF) EndIf $test = Test($i) If Not @error And $test Then ConsoleWrite("Test exist KO ==> " & $test[2] & @LF) Else ConsoleWrite("Error Test exist KO" & @LF) EndIf Next Exit Func Test($vSID) Local $pSID, $aAcct[3] If $vSID = 1 Then Return SetError(-1, 0, 0) If $vSID = 2 Then Return 0 Local $aAcct[3] $aAcct[0] = "Name" $aAcct[1] = "Domain" $aAcct[2] = "SNU" Return $aAcct EndFunc ;==>Test
  2. Ah OK, thanks you So was the behavior of the version 3.2.12.1 that was wrong ? Good day
  3. Hello, With version 3.3.0.0, it seems that the discovery of the windows using the class no longer works as before Example: Write a script and compile TestEdit.au3 (see below) Write a script and execute test.au3 with version 3.2.12.1 and 3.3.0.0 (see below) Test the script works correctly on the version 3.2.12.1 and not in the version 3.3.0.0 An idea? Thank you for your opinion ===================== Bonjour, Avec la version 3.3.0.0, il semble que la découverte des fenetres en utilisant les CLASS ne fonctionne plus comme avant Exemple : Ecrire un script TestEdit.au3 et le compiler (voir plus bas) Ecrire un script test.au3 et l'exécuter avec les version 3.2.12.1 et 3.3.0.0 (voir plus bas) Le script Test fonctionne correctement sous la version 3.2.12.1 et pas sous la version 3.3.0.0 Une idée ? Merci pour vos avis ===================== ==> TestEdit.au3 include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Test EDIT", 633, 454, 193, 115) $Edit1 = GUICtrlCreateEdit("", 48, 24, 209, 121) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Button1", 72, 192, 89, 49, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ==> Test.au3 Run(@ScriptDir & "\TestEdit.exe", @ScriptDir) If WinWait('[TITLE:Test EDIT;CLASS:Edit;INSTANCE:1]', '', 3) Then MsgBox(4096, "test edit", "Détection OK") Else MsgBox(4096, "test edit", "Non détecté") EndIf If WinWait('[TITLE:Test EDIT;CLASS:Button;INSTANCE:1]', '', 3) Then MsgBox(4096, "test bouton", "Détection OK") Else MsgBox(4096, "test bouton", "Non détecté") EndIf ProcessClose("TestEdit.exe")
  4. I found : I could not yet test all the type of data but that already made a base. On the other hand, one of you know it average to list the attributes (idem listattr) in a Novell directory? Global $dicADsType = ObjCreate("Scripting.Dictionary") $dicADsType.Add (0, "INVALID") $dicADsType.Add (1, "DN_STRING") $dicADsType.Add (2, "CASE_EXACT_STRING") $dicADsType.Add (3, "CASE_IGNORE_STRING") $dicADsType.Add (4, "PRINTABLE_STRING") $dicADsType.Add (5, "NUMERIC_STRING") $dicADsType.Add (6, "BOOLEAN") $dicADsType.Add (7, "INTEGER") $dicADsType.Add (8, "OCTET_STRING") $dicADsType.Add (9, "UTC_TIME") $dicADsType.Add (10, "LARGE_INTEGER") $dicADsType.Add (11, "PROV_SPECIFIC") $dicADsType.Add (12, "OBJECT_CLASS") $dicADsType.Add (13, "CASEIGNORE_LIST") $dicADsType.Add (14, "OCTET_LIST") $dicADsType.Add (15, "PATH") $dicADsType.Add (16, "POSTALADDRESS") $dicADsType.Add (17, "TIMESTAMP") $dicADsType.Add (18, "BACKLINK") $dicADsType.Add (19, "TYPEDNAME") $dicADsType.Add (20, "HOLD") $dicADsType.Add (21, "NETADDRESS") $dicADsType.Add (22, "REPLICAPOINTER") $dicADsType.Add (23, "FAXNUMBER") $dicADsType.Add (24, "EMAIL") $dicADsType.Add (25, "NT_SECURITY_DESCRIPTOR") $dicADsType.Add (26, "UNKNOWN") $dicADsType.Add (27, "DN_WITH_BINARY") $dicADsType.Add (28, "DN_WITH_STRING") Global $dicNtSecurity = ObjCreate("Scripting.Dictionary") $dicNtSecurity.Add (0, "Control") $dicNtSecurity.Add (1, "Group") $dicNtSecurity.Add (2, "Owner") $dicNtSecurity.Add (3, "Revision") Global $vbs, $Resultat DeclareFuncVBS() Demo() Exit Func Demo() Local $Resultat Local $objDsOpenObject = ObjGet("LDAP:") Local $objUser = $objDsOpenObject.OpenDSObject ("LDAP://cn=MyAccount,ou=users,dc=MyDomain,dc=organisation,dc=fr", "AdminAccount", "PWDAdmin", 0) Local $Attr = ListAttr("/schema/user") $objUser.GetInfo For $i = 1 To $Attr[0] $Resultat = PrintProperty($objUser.GetPropertyItem ($Attr[$i], 26), $Attr[$i]) Next EndFunc ;==>Demo Func ListAttr($DeQuoi) Local $Attributs Dim $Attr[1] $Attr[0] = 0 $Attributs = ObjGet("LDAP://" & $DeQuoi) If IsObj($Attributs) Then If IsArray($Attributs.MandatoryProperties) Then For $MandatoryProperties In $Attributs.MandatoryProperties ReDim $Attr[uBound($Attr) + 1] $Attr[0] += 1 $Attr[uBound($Attr) - 1] = $MandatoryProperties Next EndIf If IsArray($Attributs.OptionalProperties) Then For $OptionalProperties In $Attributs.OptionalProperties ReDim $Attr[uBound($Attr) + 1] $Attr[0] += 1 $Attr[uBound($Attr) - 1] = $OptionalProperties Next EndIf EndIf If $Attr[0] = 0 Then SetError(1) EndIf Return $Attr EndFunc ;==>ListAttr Func PrintProperty($propEntry, $Attribut) Local $objLargeInt, $Value, $SecurityDescriptor, $dacl, $sacl, $Inc, $Resultat If IsArray($propEntry.Values) Then ConsoleWrite("============================= " & $Attribut & " est un tableau de " & UBound($propEntry.Values) & " dimension(s) ==================================" & @LF) Dim $Resultat[uBound($propEntry.Values) ] $Inc = 0 For $propVal In $propEntry.Values Switch $dicADsType ($propVal.ADsType) Case "INVALID" $Resultat[$Inc] = "" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & "Donnée invalide") Case "DN_STRING" $Resultat[$Inc] = $propVal.DNSTRING ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "CASE_EXACT_STRING" $Resultat[$Inc] = $propVal.CaseExactString ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "CASE_IGNORE_STRING" $Resultat[$Inc] = $propVal.CaseIgnoreString ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "PRINTABLE_STRING" $Resultat[$Inc] = $propVal.PrintableString ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "NUMERIC_STRING" $Resultat[$Inc] = $propVal.NUMERICSTRING ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "BOOLEAN" $Resultat[$Inc] = (BitAND($propVal.BOOLEAN, 1) = 1) ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "INTEGER" $Resultat[$Inc] = $propVal.INTEGER ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "OCTET_STRING" $Value = OctetToHexStr($propVal.OCTETSTRING) If (StringLen($Value) / 2) = 28 Then ; Il s'agit d'un SID ReDim $Resultat[uBound($Resultat, 1) ][2] $Resultat[$Inc][0] = $Value $Resultat[$Inc][1] = HexStrToDecStr($Value) ConsoleWrite($dicADsType ($propVal.ADsType) & " (SID) ==>" & $Resultat[$Inc][0] & " (" & $Resultat[$Inc][1] & ")") Else $Resultat[$Inc] = $Value ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) EndIf Case "UTC_TIME" $Resultat[$Inc] = $propVal.UTCTIME ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "LARGE_INTEGER" $objLargeInt = $propVal.LargeInteger $Resultat[$Inc] = $objLargeInt.HighPart * 2 ^ 32 + $objLargeInt.LowPart ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "PROV_SPECIFIC" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "OBJECT_CLASS" $Resultat[$Inc] = $propVal.OBJECTCLASS ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "CASEIGNORE_LIST" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "OCTET_LIST" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "PATH" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "POSTALADDRESS" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "TIMESTAMP" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "BACKLINK" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "TYPEDNAME" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "HOLD" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "NETADDRESS" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "REPLICAPOINTER" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "FAXNUMBER" $Resultat[$Inc] = $propVal.FaxNumber ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "EMAIL" $Resultat[$Inc] = $propVal.Email ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "NT_SECURITY_DESCRIPTOR" $SecurityDescriptor = $propVal.SecurityDescriptor ReDim $Resultat[uBound($Resultat, 1) ][$dicNtSecurity.Count] $Resultat[$Inc][0] = $SecurityDescriptor.Control $Resultat[$Inc][1] = $SecurityDescriptor.Group $Resultat[$Inc][2] = $SecurityDescriptor.Owner $Resultat[$Inc][3] = $SecurityDescriptor.Revision ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & @LF) For $z = 0 To $dicNtSecurity.Count - 1 ConsoleWrite(" " & $dicNtSecurity.Item ($z) & "=" & $Resultat[$Inc][$z] & @LF) Next Case "UNKNOWN" $Resultat[$Inc] = "" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & "Donnée inconnue") Case "DN_WITH_BINARY" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case "DN_WITH_STRING" $Resultat[$Inc] = "<" & $dicADsType ($propVal.ADsType) & ">" ConsoleWrite($dicADsType ($propVal.ADsType) & "==>" & $Resultat[$Inc]) Case Else $Resultat[$Inc] = "" ConsoleWrite("Impossible de manipuler une propriété de type : " & $dicADsType ($propVal.ADsType)) EndSwitch ConsoleWrite(@LF) $Inc += 1 Next Else ;~ ConsoleWrite($Attribut & " n'est pas une donnée de l'objet" & @LF) $Resultat = "" EndIf Return $Resultat EndFunc ;==>PrintProperty Func DeclareFuncVBS() Local $s_Quotes = '"' Local $code $code = "Function vbsOctetToHexStr(arrbytOctet)" $code = $code & @CRLF & "Dim k" $code = $code & @CRLF & "vbsOctetToHexStr = """"" $code = $code & @CRLF & "For k = 1 To LenB(arrbytOctet)" $code = $code & @CRLF & "vbsOctetToHexStr = vbsOctetToHexStr & Right(""0"" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)" $code = $code & @CRLF & "Next" $code = $code & @CRLF & "end Function" $vbs = ObjCreate("ScriptControl") $vbs.language = "vbscript" $vbs.addcode ($code) $code = "Function vbsTypeName(VarName)" $code = $code & @CRLF & "vbsTypeName = TypeName(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsIsEmpty(VarName)" $code = $code & @CRLF & "vbsIsEmpty = IsEmpty(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsIsNull(VarName)" $code = $code & @CRLF & "vbsIsNull = IsNull(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsIsNothing(VarName)" $code = $code & @CRLF & "vbsIsNothing = IsNothing(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsLenB(VarName)" $code = $code & @CRLF & "vbsLenB = LenB(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) EndFunc ;==>DeclareFuncVBS Func OctetToHexStr($arrbytOctet) Local $retour = $vbs.run ("vbsOctetToHexStr", $arrbytOctet) Return $retour EndFunc ;==>OctetToHexStr Func TypeName($VarName) Local $retour = $vbs.run ("vbsTypeName", $VarName) Return $retour EndFunc ;==>TypeName Func IsEmpty($VarName) Local $retour = $vbs.run ("vbsIsEmpty", $VarName) Return $retour EndFunc ;==>IsEmpty Func IsNull($VarName) Local $retour = $vbs.run ("vbsIsNull", $VarName) Return $retour EndFunc ;==>IsNull Func IsNothing($VarName) Local $retour = $vbs.run ("vbsIsNothing", $VarName) Return $retour EndFunc ;==>IsNothing Func LenB($VarName) Local $retour = $vbs.run ("vbsLenB", $VarName) Return $retour EndFunc ;==>LenB ; Converti une valeur SID au format hexa en format décimal Func HexStrToDecStr($strSid) Local $Return = "" ; Function to convert Sid value in hex format ; to decimal display format. Dim $arrbytSid[1], $lngTemp, $j ReDim $arrbytSid[stringLen($strSid) / 2 - 1] For $j = 0 To UBound($arrbytSid) - 1 $arrbytSid[$j] = Number("0x" & StringMid($strSid, 2 * $j + 1, 2)) Next $Return = "S-" & $arrbytSid[0] & "-" & $arrbytSid[1] & "-" & $arrbytSid[8] $lngTemp = $arrbytSid[15] $lngTemp = $lngTemp * 256 + $arrbytSid[14] $lngTemp = $lngTemp * 256 + $arrbytSid[13] $lngTemp = $lngTemp * 256 + $arrbytSid[12] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[19] $lngTemp = $lngTemp * 256 + $arrbytSid[18] $lngTemp = $lngTemp * 256 + $arrbytSid[17] $lngTemp = $lngTemp * 256 + $arrbytSid[16] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[23] $lngTemp = $lngTemp * 256 + $arrbytSid[22] $lngTemp = $lngTemp * 256 + $arrbytSid[21] $lngTemp = $lngTemp * 256 + $arrbytSid[20] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[25] $lngTemp = $lngTemp * 256 + $arrbytSid[24] $Return = $Return & "-" & String($lngTemp) Return $Return EndFunc ;==>HexStrToDecStr
  5. Hi, how to obtain by script the complete list of the attributes available in a object resulting from a request LDAP, like their type of data? Exemple : Local $objDsOpenObject = ObjGet("LDAP:") Local $objUserDomain = $objDsOpenObject.OpenDSObject ("LDAP://cn=MyAccount,ou=users,dc=MyDomain,dc=organisation,dc=fr", "AdminAccount", "PWDAdmin", 0) I want to list all the attributes and their type of data Exemple : msgbox(0,"test", $objUserDomain.DisplayName & @lf & $objUserDomain.sAMAccountName ....) Thanks you for your answer Eric
  6. Hi, I try to read attributes of accounts in a Novell e-directory. How to read an attribute which contains a character minus ? example: DirXML-associations ==> Const $ServeurNDS = "MyServer" Const $PortNDS = 389 Const $AdmNDS = "cn=MyUser,o=MyContext" Const $PWDNDS = "MyPWD" Global $User="cn=MyAccount,ou=MyContext,o=MyOrganisation" $oLDAP = ObjGet("LDAP:") If IsObj($oLDAP) Then $oADsSelectContainer = $oLDAP.OpenDSObject ("LDAP://" & $ServeurNDS & ":" & $PortNDS & "/" & $User, $AdmNDS, $PWDNDS, 0) If Not @error Then If $oADsSelectContainer.sn <> "" Then Msgbox(4096, $oADsSelectContainer.sn, "DIRXML=" & $oADsSelectContainer.DirXML-associations) EndIf EndIf EndIf With this code, I have an error of compilation on $oADsSelectContainer.DirXML-associations Thanks for your answer Eric
  7. Filecopy("\\server\VOL1\Snaps\WinXP\XP_Misys Laboratory\v6.1.0120\Misys Laboratory v6.1.0120.msi", @tempdir & "\Misys Laboratory v6.1.0120.msi", 0) If Not IsAdmin() Then RunAsSet("administrator", @ComputerName, "password") EndIf RunWait('msiexec /i "' & @tempdir & '\Misys Laboratory v6.1.0120.msi"', @TempDir) RunAsSet() Filedelete(@tempdir & "\Misys Laboratory v6.1.0120.msi")
  8. My problem has this level. $arrbyteSids is not a pointer ==> How to create a pointer on a variable which is not a structure? I want : Local $objUser = ObjGet("LDAP://cn=CHAIGNE Eric,ou=users,dc=MyDomain,dc=fr") Local $arrbytSids = $objUser.objectSid Local $arrbytSidsHist = $objUser.SIDHistory $rSID = DllStructCreate("byte[256]", a pointer on $arrbytSids (or on $objUser.objectSid) ==> How create it ?????) $rSIDhist = DllStructCreate("byte[256]", a pointer on $arrbytSidsHist (or on $objUser.SIDHistory) ==> How create it ?????) _ConvertSidToStringSid(DllStructGetPtr($rSID) _ConvertSidToStringSid(DllStructGetPtr($rSIDhist )
  9. Precisely, I do not want to pass by OctetToHexStr ==> ; Essai avec des structures et des appels de fonctions Local $BinSID = OctetToHexStr($arrbytSids) ; How to use the value arrbytSids directly for creating structure ????????????????????????????????????????? Local $rSID = DllStructCreate("byte[" & StringLen($BinSID) / 2 & "]") Local $pSID = DllStructGetPtr($rSID) Local $j = 1 For $i = 1 To StringLen($BinSID) Step 2 DllStructSetData($rSID, 1, Dec(StringMid($BinSID, $i, 2)), $j) $j += 1 Next MsgBox(0, "Test structures", _ConvertSidToStringSid ($pSID)) I want suppress all this lines and replace by MsgBox(0, "Test structures", _ConvertSidToStringSid ($pSID)) where $pSID is a pointer on arrbytSids (arrbytSids = $objUser.objectSid or $objUser.SIDhistory according to the cases)
  10. But, in your example, you master keys a structure in parameter, with the result that you can use the functions to find the pointer. In my case, the type of value indicated (by functions VBS) by TypeName is Byte () and I do not see how to convert this data of structure
  11. Hi, I still subject a problem of conversion: When one carries out requests LDAP to recover, for example, the SID or SIDhistory, the type of turned over value is Byte(). How used this type of value directly in AutoIt, without passing by routines of binary conversion towards string then string towards structures (see TestConversion function) AutoItSetOption("MustDeclareVars", 1) AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconDebug", 1) ; src : http://www.autoitscript.com/forum/index.php?showtopic=33677 #include <A3LLibrary.au3> #include <A3LSecurity.au3> Const $Debug = 0 Global $vbs DeclareFuncVBS() Test() Exit Func Test() Local $TestSID, $pSID Local $objUser = ObjGet("LDAP://cn=CHAIGNE Eric,ou=users,ou=test,dc=Domaine,dc=fr") Local $arrbytSids, $arrbytSidsHist $arrbytSids = $objUser.objectSid $arrbytSidsHist = $objUser.SIDHistory TestSID($arrbytSids) TestSID($arrbytSidsHist) EndFunc ;==>Test Func TestSID($arrbytSids) If IsEmpty($arrbytSids) Then MsgBox(0, "Test", "Pas de SID") Else If TypeName($arrbytSids) = "Byte()" Then TestConversion($arrbytSids) Else For $j = 0 To UBound($arrbytSids) - 1 TestConversion($arrbytSids[$j]) Next EndIf EndIf EndFunc ;==>TestSID Func TestConversion($arrbytSids) ; Essai avec des fonctions de conversion MsgBox(0, "Test conversion", OctetToHexStr($arrbytSids) & @LF & HexStrToDecStr(OctetToHexStr($arrbytSids)) & @LF & AccountFromSID(HexStrToDecStr(OctetToHexStr($arrbytSids)))) ; Essai avec des structures et des appels de fonctions Local $BinSID = OctetToHexStr($arrbytSids) ; How to use the value arrbytSids directly for creating structure ????????????????????????????????????????? Local $rSID = DllStructCreate("byte[" & StringLen($BinSID) / 2 & "]") Local $pSID = DllStructGetPtr($rSID) Local $j = 1 For $i = 1 To StringLen($BinSID) Step 2 DllStructSetData($rSID, 1, Dec(StringMid($BinSID, $i, 2)), $j) $j += 1 Next MsgBox(0, "Test structures", _ConvertSidToStringSid ($pSID)) EndFunc ;==>TestConversion ; Trouve le SID texte d'un compte ; Entrée : Compte à décomposer (Domaine\Compte) ; Retourne une chaine contenant le SID au format texte (de type : S-1-5-21-1960408961-583907252-839522115-26511) Func TrouveSID($AccountATrouver) Local $SIDstr = "" Local $Result = _LookupAccountName ($AccountATrouver) Local $OK = $Result[0] If $OK Then Local $SID = $Result[1] Local $Domain = $Result[2] Local $SIDtype = _ConvertSidTypeToStr ($Result[3]) If $Debug Then MsgBox(4096, "_LookupAccountName", "OK=" & $OK & @LF & "Domain=" & $Domain & @LF & "Type de SID=" & $SIDtype & @LF & "SID=" & $SID) EndIf Return $SID Else SetError(1) Return "" EndIf EndFunc ;==>TrouveSID ; Trouve le compte lié à un SID texte ; Entrée : SID au format texte ou pointeur sur une structure binaire ; Retourne une chaine contenant Domaine\Compte Func AccountFromSID($SID) Local $Result = _LookupAccountSid ($SID) Local $OK = $Result[0] If $OK Then Local $Account = $Result[1] Local $Domain = $Result[2] Local $SIDtype = _ConvertSidTypeToStr ($Result[3]) If $Debug Then MsgBox(4096, "_LookupAccountSid", "OK=" & $OK & @LF & "Domain=" & $Domain & @LF & "Type SID=" & $SIDtype & @LF & "Account=" & $Account) EndIf Return $Domain & "\" & $Account Else SetError(1) Return "" EndIf EndFunc ;==>AccountFromSID Func DeclareFuncVBS() Local $s_Quotes = '"' Local $code $code = "Function vbsOctetToHexStr(arrbytOctet)" $code = $code & @CRLF & "Dim k" $code = $code & @CRLF & "OctetToHexStr = """"" $code = $code & @CRLF & "For k = 1 To LenB(arrbytOctet)" $code = $code & @CRLF & "vbsOctetToHexStr = vbsOctetToHexStr & Right(""0"" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)" $code = $code & @CRLF & "Next" $code = $code & @CRLF & "end Function" $vbs = ObjCreate("ScriptControl") $vbs.language = "vbscript" $vbs.addcode ($code) $code = "Function vbsTypeName(VarName)" $code = $code & @CRLF & "vbsTypeName = TypeName(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsIsEmpty(VarName)" $code = $code & @CRLF & "vbsIsEmpty = IsEmpty(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) $code = "Function vbsLenB(VarName)" $code = $code & @CRLF & "vbsLenB = LenB(VarName)" $code = $code & @CRLF & "end Function" $vbs.addcode ($code) EndFunc ;==>DeclareFuncVBS Func OctetToHexStr($arrbytOctet) Local $retour = $vbs.run ("vbsOctetToHexStr", $arrbytOctet) Return $retour EndFunc ;==>OctetToHexStr Func TypeName($VarName) Local $retour = $vbs.run ("vbsTypeName", $VarName) Return $retour EndFunc ;==>TypeName Func IsEmpty($VarName) Local $retour = $vbs.run ("vbsIsEmpty", $VarName) Return $retour EndFunc ;==>IsEmpty Func LenB($VarName) Local $retour = $vbs.run ("vbsLenB", $VarName) Return $retour EndFunc ;==>LenB Func HexStrToDecStr($strSid) Local $Return = "" ; Function to convert Sid value in hex format ; to decimal display format. Dim $arrbytSid[1], $lngTemp, $j ReDim $arrbytSid[stringLen($strSid) / 2 - 1] For $j = 0 To UBound($arrbytSid) - 1 $arrbytSid[$j] = Number("0x" & StringMid($strSid, 2 * $j + 1, 2)) Next $Return = "S-" & $arrbytSid[0] & "-" & $arrbytSid[1] & "-" & $arrbytSid[8] $lngTemp = $arrbytSid[15] $lngTemp = $lngTemp * 256 + $arrbytSid[14] $lngTemp = $lngTemp * 256 + $arrbytSid[13] $lngTemp = $lngTemp * 256 + $arrbytSid[12] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[19] $lngTemp = $lngTemp * 256 + $arrbytSid[18] $lngTemp = $lngTemp * 256 + $arrbytSid[17] $lngTemp = $lngTemp * 256 + $arrbytSid[16] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[23] $lngTemp = $lngTemp * 256 + $arrbytSid[22] $lngTemp = $lngTemp * 256 + $arrbytSid[21] $lngTemp = $lngTemp * 256 + $arrbytSid[20] $Return = $Return & "-" & String($lngTemp) $lngTemp = $arrbytSid[25] $lngTemp = $lngTemp * 256 + $arrbytSid[24] $Return = $Return & "-" & String($lngTemp) Return $Return EndFunc ;==>HexStrToDecStr
  12. Thank youPaul, I tested and your new code functions with wonder. I will have some ideas on functions to add to your librairie, which exists in VBS but not in AutoIt, for example ==> - TypeName (the type of value of a variable returns) - IsEmpty (Indicates if a variable is empty) - Data conversion resulting from requests LDAP i.e. $objUser.SIDhistory: I manage to treat the result via code VBS integrated in my AutoIt script but not in pure AutoIt. there must be method which I do not manage to find ... Bye Eric
  13. Thank you, I await your new version in order to update my code but you could perhaps include the functions of transformation of SID text --> binary and vice versa in your librairy. I believe that these functions could be useful to several people?
  14. If you to test the code by remplacant the line "$TestSID = TrouveSID(@computername & "\eric")" by $TestSID = TrouveSID(@computername & "\Your account") under 3 tests: 1: Just as it is ==> OK 2: To comment on the line "Local $BinSID = String(DllStructGetData($Result, 2))" ==> KO 3: To place $Debug at 1 (what amounts using the order used by the line "Local $BinSID = String(DllStructGetData($Result, 2))" ==> OK Conclusion: I do not understand why the fact of placing the code "Local $BinSID = String(DllStructGetData($Result, 2))" allows to make function the remainder of the program correctly whereas the structure is not used elsewhere than in the function ? Thank you for your answer Eric
  15. Hi, excuse me for my bad English. With an aim of writing programs of migration, I try to find the SID binary of a user starting from his account, to transform this SID into format text then to return in arrear, i.e. to find the account starting from the conversion of the SID text into binary SID then to find the account to use associated with the binary SID (I need the binary SID to treat the SID history) The program listed below functions but, so that the late return functions, I must carry out the conversion of a field of structure of the type byte [256] which is not useful to me then any more in string (line surrounded by ***) Do you have an idea on the fact of converting a value which is not useful any more after transformation, in order to make function the code located apart from the function? Thank you by advance AutoItSetOption("MustDeclareVars", 1) AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconDebug", 1) ; src of include under http://www.autoitscript.com/forum/index.php?showtopic=33677 #include <A3LLibrary.au3> #include <A3LSecurity.au3> Const $Debug = 0 Test() Exit Func Test() Local $TestSID $TestSID = TrouveSID(@computername & "\eric") MsgBox(4096, "Trouve SID", "SID trouvé=" & $TestSID) If $TestSID <> "" Then MsgBox(4096, "Account trouvé", AccountFromSID($TestSID)) EndIf _DllClose () EndFunc ;==>Test ; Trouve le SID texte d'un compte ; Entrée : Compte à décomposer (Domaine\Compte) ; Retourne une chaine contenant le SID au format texte (de type : S-1-5-21-1960408961-583907252-839522115-26511) Func TrouveSID($AccountATrouver) Local $SIDstr = "" Local $Result = _LookupAccountName ($AccountATrouver) Local $OK = DllStructGetData($Result, 1) Local $pSID = DllStructGetPtr($Result, 2) Local $Domain = DllStructGetData($Result, 3) Local $SIDtype = DllStructGetData($Result, 4) If IsValidSID(DllStructGetPtr($Result, 2)) Then If $Debug Then MsgBox(4096, "_LookupAccountName", "OK=" & $OK & @LF & "Domain=" & $Domain & @LF & "Type de SID=" & $SIDtype & @LF & "SID binaire=" & String(DllStructGetData($Result, 2)) & @LF & "Longueur du SID=" & LngSID(DllStructGetPtr($Result, 2))) EndIf $SIDstr = SIDtoStr($pSID) ; **************************************************************************************************** ***************** ; Si cette ligne n'est pas présente (ou si la valeur $Debug est à 0), le code inverse ne fonctionne pas (récupération du compte à partir du SID) ??????? ; If this line is not present (or if the value $Debug is with the 0), the opposite code does not function (recovery of the account starting from the SID)??????? ; **************************************************************************************************** ***************** Local $BinSID = String(DllStructGetData($Result, 2)) ; **************************************************************************************************** ***************** $Result = 0 Return $SIDstr Else SetError(1) Return "" EndIf EndFunc ;==>TrouveSID ; Trouve le compte lié à un SID texte ; Entrée : SID au format texte (ex : S-1-5-21-1960408961-583907252-839522115-26511) ; Retourne une chaine contenant Domaine\Compte Func AccountFromSID($SID) Local $pSIDbin = TrouveSIDbin($SID) If $pSIDbin <> "" Then Local $Result = _LookupAccountSid ($pSIDbin) Local $OK = DllStructGetData($Result, 1) Local $Account = DllStructGetData($Result, 2) Local $Domain = DllStructGetData($Result, 3) Local $SIDtype = DllStructGetData($Result, 4) If $Debug Then MsgBox(4096, "_LookupAccountSid", "OK=" & $OK & @LF & "Domain=" & $Domain & @LF & "Type SID=" & $SIDtype & @LF & "Account=" & $Account) EndIf Return $Domain & "\" & $Account Else SetError(1) Return "" EndIf EndFunc ;==>AccountFromSID ; Trouve le SID binaire d'un SID texte ; Entrée : SID au format texte (ex : S-1-5-21-1960408961-583907252-839522115-26511) ; Retourne un pointeur sur le SID binaire Func TrouveSIDbin($SID) Local $SIDstr = _DllStructCreate ("ptr;byte[256];char[256]") Local $pSID = _DllStructGetPtr ($SIDstr, 1) Local $pSIDbin = _DllStructGetPtr ($SIDstr, 2) Local $pSIDstr = _DllStructGetPtr ($SIDstr, 3) _DllStructSetData ($SIDstr, 3, $SID) Local $hAdvAPI32 = _DllOpen ("AdvAPI32.dll") Local $aResultinv = DllCall($hAdvAPI32, "int", "ConvertStringSidToSid", "ptr", $pSIDstr, "ptr", $pSID) _Check ("ConvertStringSidToSid:DllCall", @error, @error) Local $ppSIDstr = DllStructGetData($SIDstr, 1) CopyMemory($ppSIDstr, $pSIDbin, 256) If IsValidSID($pSIDbin) Then If $Debug Then MsgBox(4096, "ConvertStringSidToSid", "SID binaire=" & String(DllStructGetData($SIDstr, 2)) & @LF & "Longueur du SID=" & LngSID($pSIDbin)) EndIf If $aResultinv[0] <> 0 Then Return $pSIDbin Else Return "" EndIf Else Return "" EndIf EndFunc ;==>TrouveSIDbin ; Trouve la longueur d'un SID binaire ; Enrée : Pointeur sur le SID binaire ; Retourne la longueur du SID Func LngSID($pBinSID) Local $hAdvAPI32 = _DllOpen ("AdvAPI32.dll") Local $LngSID = DllCall($hAdvAPI32, "int", "GetLengthSid", "ptr", $pBinSID) _Check ("GetLengthSid:DllCall", @error, @error) Return $LngSID[0] EndFunc ;==>LngSID ; Vérifie si un SID binaire est valide ; Enrée : Pointeur sur le SID binaire ; Retourne True ou False Func IsValidSID($pBinSID) Local $hAdvAPI32 = _DllOpen ("AdvAPI32.dll") Local $ValidSID = DllCall($hAdvAPI32, "int", "IsValidSid", "ptr", $pBinSID) _Check ("IsValidSid:DllCall", @error, @error) Return $ValidSID[0] <> 0 EndFunc ;==>IsValidSID ; Copie un emplacement mémoire à un autre emplacement ; Entrée : Pointeur sur la source, pointeur sur la destination, longueur à déplacer Func CopyMemory(ByRef $Source, ByRef $Destination, $Lng) Local $hKernel32 = _DllOpen ("kernel32.dll") DllCall($hKernel32, "none", "RtlMoveMemory", "long", $Destination, "ptr", $Source, "long", $Lng) _Check ("RtlMoveMemory:DllCall", @error, @error) If Not @error Then Return 1 Else Return 0 EndIf EndFunc ;==>CopyMemory ; Converti un SID binaire en un SID texte ; Enrée : Pointeur sur le SID binaire ; Retourne le SID au format texte (ex: S-1-5-21-1960408961-583907252-839522115-26511) Func SIDtoStr($pBinSID) Local $Result = "" Local $SIDstr = _DllStructCreate ("ptr;char[256]") Local $pSID = _DllStructGetPtr ($SIDstr, 1) Local $pSIDstr = _DllStructGetPtr ($SIDstr, 2) Local $hAdvAPI32 = _DllOpen ("AdvAPI32.dll") Local $aResult = DllCall($hAdvAPI32, "int", "ConvertSidToStringSid", "ptr", $pBinSID, "ptr", $pSID) _Check ("ConvertSidToStringSid:DllCall", @error, @error) Local $ppSIDstr = DllStructGetData($SIDstr, 1) CopyMemory($ppSIDstr, $pSIDstr, 256) If $aResult[0] <> 0 Then $Result = DllStructGetData($SIDstr, 2) $SIDstr = "" Return $Result Else Return "" EndIf EndFunc ;==>SIDtoStr
×
×
  • Create New...