SkiFreak Posted July 17, 2007 Share Posted July 17, 2007 I am obviously missing something very simple here but be damned if I can figure out what to do. I am converting a fairly basic .vbs script into an .au3 script (or trying to) but I am stuck. This is the VBS code: Dim objShell : Set objShell = CreateObject("Wscript.Shell") Dim objEnv : set objEnv = objShell.Environment("Process") Dim CompEnv0: CompEnv0 = Left(objEnv("COMPUTERNAME"), 4) msgbox GetSiteDescription ("some.domain.com") Function GetSiteDescription(sLongDomainName) dim objConnection, objCommand, arrFQDN, objRecordSet, objOU Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection arrFQDN=split(sLongDomainName,".") objCommand.CommandText = "<LDAP://OU=LOCATIONS,OU=DEPT" & ",DC=" & arrFQDN(Ubound(arrFQDN)-2) & ",DC=" & arrFQDN(Ubound(arrFQDN)-1) & ",DC=" & arrFQDN(Ubound(arrFQDN)) & ">;(&(objectCategory=organizationalunit)(name=*"& CompEnv0 &"));Name,distinguishedName,description;subtree" Set objRecordSet = objCommand.Execute Set objOU = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName")) GetSiteDescription=objOU.get("description") objConnection.Close End Function This is the AU3 code I have: Dim $objShell Dim $objEnv Dim $CompEnv0 Dim $Description $objShell = ObjCreate("Wscript.Shell") $objEnv = $objShell.Environment("Process") $CompEnv0 = StringLeft($objEnv("COMPUTERNAME"), 4) GetSiteDescription ("some.domain.com") MsgBox(0,"",$Description) Func GetSiteDescription($sLongDomainName) Dim $objConnection, $objCommand, $arrFQDN, $objRecordSet, $objOU $objConnection = ObjCreate("ADODB.Connection") $objConnection.Open("Provider=ADsDSOObject;") $objCommand = ObjCreate("ADODB.Command") $objCommand.ActiveConnection = $objConnection $arrFQDN=StringSplit($sLongDomainName,".") $objCommand.CommandText = "<LDAP://OU=LOCATIONS,OU=DEPT" & ",DC=" & $arrFQDN[1] & ",DC=" & $arrFQDN[2] & ",DC=" & $arrFQDN[3] & ">;(&(objectCategory=organizationalunit)(name=*"& $CompEnv0 &"));Name,distinguishedName,description;subtree" $objRecordSet = $objCommand.Execute $objOU = ObjGet("LDAP://" & $objRecordSet.Fields("distinguishedName")) $Description=$objOU.Get("description") $objConnection.Close Return $Description EndFunc The VBS runs fine and returns the desired container description but the AU3 script returns: $Description=$objOU.Get("description") $Description=$objOU^ ERROR Error: Variable must be of type "Object" I need to be shown the light . . . Link to comment Share on other sites More sharing options...
arcker Posted July 17, 2007 Share Posted July 17, 2007 look in the autoit help grab the code for com errors and after please post it here, and i will help you. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
SkiFreak Posted July 17, 2007 Author Share Posted July 17, 2007 look in the autoit help grab the code for com errors and after please post it here, and i will help you. I have no idea as to what type of error handler I should put in here that would be useful. Nothing in AutoIt help has come close to helping me resolve this problem. The error that is being returned is saying that the variable is not an object. There is one line of code in my script that is returning this error, just one. That is the AutoIt line: $Description=$objOU.Get("description") All I need to know is what AutoIt is doing when the VBS script equivialant [GetSiteDescription=objOU.get("description")] works just fine. As stated previously; the VBS works, my AutoIt conversion does not. That's what I need help with. Link to comment Share on other sites More sharing options...
SkiFreak Posted July 17, 2007 Author Share Posted July 17, 2007 Obviously direct conversions of VBS do not always work. Went at it another way and all is working now. $objRecordSet = $objCommand.Execute $DistListing = $objRecordSet.Fields("DistinguishedName").value $objConnection.Close $objDescription = ObjGet("LDAP://"& $DistListing) $Description = $objDescription.description Return $Description = $objDescription.description Link to comment Share on other sites More sharing options...
ptrex Posted July 17, 2007 Share Posted July 17, 2007 @SkiFreak This an other example expandcollapse popupLocal $objCommand = ObjCreate("ADODB.Command") Local $objConnection = ObjCreate("ADODB.Connection") $objConnection.Provider = "ADsDSOObject" $objConnection.Open ("Active Directory Provider") $objCommand.ActiveConnection = $objConnection Local $strBase = "<GC://dc=YOURDOMAIN,dc=COUNTRY>" Local $strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=*))" Local $strAttributes = "cn,sAMAccountName,displayName,sn,distinguishedName" Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree" $objCommand.CommandText = $strQuery $objCommand.Properties ("Page Size") = 100 $objCommand.Properties ("Timeout") = 30 $objCommand.Properties ("Cache Results") = False $ADS_SCOPE_SUBTREE = 2 $objCommand.Properties ("searchscope") = $ADS_SCOPE_SUBTREE Local $objRecordSet = $objCommand.Execute ConsoleWrite("Users"&@CR&"---------"&@CR) While Not $objRecordSet.EOF $strName = $objRecordSet.Fields ("sAMAccountName").Value $strCN = $objRecordSet.Fields ("cn").value $strdisplayName = $objRecordSet.Fields ("displayName").value $strSN = $objRecordSet.Fields ("SN").value $strdistinguishedName = $objRecordSet.Fields ("distinguishedName").value ;FileWriteLine("Users.txt",$objRecordSet.Fields ("sAMAccountName").Value) ConsoleWrite($objRecordSet.Fields ("sAMAccountName").Value&@cr) $objRecordSet.MoveNext WEnd $objConnection.Close $objConnection = "" $objCommand = "" $objRecordSet = "" Enjoy !! Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 11, 2007 Share Posted October 11, 2007 (edited) Hi ptrex, i know this isn't a AutoIt specific question but more a leck of knowledge on my side. In youre example you are reading some values like sn and display name. When i browse our AD structure using a ldap browser i see nearly 40 fields for every user. Like department, employeeID and so on. I could read all those values by hand but how can i get the whole set of data and put them into a two-dimensional array like without hardcoding the fieldnames? Should look like this: cn Sundance company big one employeeID 123456 . . . Do you have any ideas? I've searched the internet but haven't found something similar.. thx in advance Sundance @SkiFreak This an other example expandcollapse popupLocal $objCommand = ObjCreate("ADODB.Command") Local $objConnection = ObjCreate("ADODB.Connection") $objConnection.Provider = "ADsDSOObject" $objConnection.Open ("Active Directory Provider") $objCommand.ActiveConnection = $objConnection Local $strBase = "<GC://dc=YOURDOMAIN,dc=COUNTRY>" Local $strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=*))" Local $strAttributes = "cn,sAMAccountName,displayName,sn,distinguishedName" Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree" $objCommand.CommandText = $strQuery $objCommand.Properties ("Page Size") = 100 $objCommand.Properties ("Timeout") = 30 $objCommand.Properties ("Cache Results") = False $ADS_SCOPE_SUBTREE = 2 $objCommand.Properties ("searchscope") = $ADS_SCOPE_SUBTREE Local $objRecordSet = $objCommand.Execute ConsoleWrite("Users"&@CR&"---------"&@CR) While Not $objRecordSet.EOF $strName = $objRecordSet.Fields ("sAMAccountName").Value $strCN = $objRecordSet.Fields ("cn").value $strdisplayName = $objRecordSet.Fields ("displayName").value $strSN = $objRecordSet.Fields ("SN").value $strdistinguishedName = $objRecordSet.Fields ("distinguishedName").value ;FileWriteLine("Users.txt",$objRecordSet.Fields ("sAMAccountName").Value) ConsoleWrite($objRecordSet.Fields ("sAMAccountName").Value&@cr) $objRecordSet.MoveNext WEnd $objConnection.Close $objConnection = "" $objCommand = "" $objRecordSet = "" Enjoy !! Edited October 11, 2007 by Sundance Link to comment Share on other sites More sharing options...
Sundance Posted October 11, 2007 Share Posted October 11, 2007 I found the solution with the help of the MSDN..... Link to comment Share on other sites More sharing options...
ptrex Posted October 11, 2007 Share Posted October 11, 2007 @Sundance Good to hear you found the solution. But it's good post sometimes what you found so others can benifit of this a well. Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 11, 2007 Share Posted October 11, 2007 (edited) I thought you would say that. But i need to do some mod before i post it. One moment.... So here it is: Func _ADGetUserProperties(ByRef $userprops, $user = @UserName) Local $oUsr Local $localUserProps[1] $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $user & ");ADsPath;subtree" $objRecordSet = $objConnection.Execute ($strQuery); Retrieve the FQDN for the logged on user $ldap_entry = $objRecordSet.fields (0).value $oUsr = ObjGet($ldap_entry); Retrieve the COM Object for the logged on user $userprops = $oUsr.GetInfo() $NumberOfDataObjects = $oUsr.PropertyCount() For $i = 0 To $NumberOfDataObjects $item = $oUsr.Item($i) $propentry = $oUsr.GetEx($item.Name) For $j = 0 To UBound($propentry) - 1 _ArrayAdd($localUserProps,$item.Name & " || " & $propentry[$j]) $userprops = $localUserProps Next Next $oUsr = 0 EndFunc;==>_ADGetUserProperties some of the code was taken from the well known adfunctions.au3 There is still the problem that you can't read some vaules like large intergers or octet strings. Haven't found the right thing on msdn. The output should be modified but for me it was okay to output a one-dimensional array. till then Sundance Edited October 11, 2007 by Sundance Link to comment Share on other sites More sharing options...
Sundance Posted October 23, 2007 Share Posted October 23, 2007 (edited) Back again, i modifed/rewrote the function _ADGetObjectProperties. It returns all possible values of a AD object and returns them in an array. It shows all values as a formatted string and it doe's like it should. The only thing which won't work ist the octet string. When i use the binary functions of AutoIt to read the byte values i get allways 0 as an answer.. Don't know any further. Has someone successfully read this kind of value? Below is the code of the function(s) expandcollapse popup; ---------------------------------------------------------------------------- ;NOTES : Please use the following command to store the local user's groups for the function 'HasFullRights'. This is to allow cross-domain ; permission checks. $loggedonusergroups is a global variable declared in the 'Define AD Constants' region. If you are using this command ; in this library, move the command below the declaration of the variable and remove the comment charcater. ; _ADRecursiveGetMemberOf ($loggedonusergroups, _ADSamAccountNameToFQDN (@UserName)) ; include array functions (we use _arraysearch in some functions) #include-once #include <Array.au3> #include <Date.au3> #region ; Define AD Constants Global Const $ADS_GROUP_TYPE_GLOBAL_GROUP = 0x2 Global Const $ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x4 Global Const $ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x8 Global Const $ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000 Global Const $ADS_GROUP_TYPE_GLOBAL_SECURITY = BitOR($ADS_GROUP_TYPE_GLOBAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED) Global Const $ADS_GROUP_TYPE_UNIVERSAL_SECURITY = BitOR($ADS_GROUP_TYPE_UNIVERSAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED) Global Const $ADS_GROUP_TYPE_DOMAIN_LOCAL_SECURITY = BitOR($ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED) Global Const $ADS_UF_PASSWD_NOTREQD = 0x0020 Global Const $ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0x1000 Global Const $ADS_ACETYPE_ACCESS_ALLOWED = 0x0 Global Const $ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = 0x5 Global Const $ADS_FLAG_OBJECT_TYPE_PRESENT = 0x1 Global Const $ADS_RIGHT_GENERIC_READ = 0x80000000 Global Const $ADS_RIGHT_DS_SELF = 0x8 Global Const $ADS_RIGHT_DS_WRITE_PROP = 0x20 Global Const $ADS_RIGHT_DS_CONTROL_ACCESS = 0x100 Global Const $ADS_UF_ACCOUNTDISABLE = 2 Global Const $ADS_OPTION_SECURITY_MASK = 3 Global Const $ADS_SECURITY_INFO_DACL = 4 Global Const $ALLOWED_TO_AUTHENTICATE = "{68B1D179-0D15-4d4f-AB71-46152E79A7BC}" Global Const $RECEIVE_AS = "{AB721A56-1E2f-11D0-9819-00AA0040529B}" Global Const $SEND_AS = "{AB721A54-1E2f-11D0-9819-00AA0040529B}" Global Const $USER_CHANGE_PASSWORD = "{AB721A53-1E2f-11D0-9819-00AA0040529b}" Global Const $USER_FORCE_CHANGE_PASSWORD = "{00299570-246D-11D0-A768-00AA006E0529}" Global Const $USER_ACCOUNT_RESTRICTIONS = "{4C164200-20C0-11D0-A768-00AA006E0529}" Global Const $VALIDATED_DNS_HOST_NAME = "{72E39547-7B18-11D1-ADEF-00C04FD8D5CD}" Global Const $VALIDATED_SPN = "{F3A64788-5306-11D1-A9C5-0000F80367C1}" Const $Member_SchemaIDGuid = "{BF9679C0-0DE6-11D0-A285-00AA003049E2}" Global $objConnection = ObjCreate("ADODB.Connection") ; Create COM object to AD $objConnection.ConnectionString = "Provider=ADsDSOObject" $objConnection.Open ("Active Directory Provider") ; Open connection to AD Global $objRootDSE = ObjGet("[url="ldap://RootDSE"]LDAP://RootDSE[/url]") Global $strDNSDomain = $objRootDSE.Get ("defaultNamingContext") ; Retrieve the current AD domain name Global $strHostServer = $objRootDSE.Get ("dnsHostName"); Retrieve the name of the connected DC Global $strConfiguration = $objRootDSE.Get ("ConfigurationNamingContext"); Retrieve the Configuration naming context Global $loggedonusergroups ; populate this with the logged on user groups in your own app #endregion Global $oMyError = ObjEvent("AutoIt.Error", "_ADDoError"); Install a custom error handler AutoItSetOption("MustDeclareVars" , 1) Local $groups Local $temp Local $Objectnames Local $members Local $Computerlist[1] Local $Cl[1][1] Local $Counter Global $Properties[1] Global $fqdn Global $attrib Global $userdata ; ; ---------------------------------------------------------------------------- ; Description : Ermittelt alle Eigenschaften eine DomainOBjects ; Syntax : _ADGetObjectProperties($object) ; Parameter(s) : $object (z.B. @Computername, @UserName oder "GruppenName") ; Requirement(s) : $object ; Return Value(s) : Ein dimensionales Array: ValueName||Data ; Note(s) : - ; ---------------------------------------------------------------------------- Func _ADGetObjectProperties($object) If not _ADObjectExists($object) Then Return 0 EndIf Local $oObject Local $localObjectProps[1] Local $strQuery Local $objRecordSet Local $ldap_entry Local $props Local $NumberOfDataObjects Local $item Local $propentry Local Const $ADSTYPE_INVALID = 0 Local const $ADSTYPE_DN_STRING = 1 Local const $ADSTYPE_CASE_EXACT_STRING = 2 Local const $ADSTYPE_CASE_IGNORE_STRING = 3 Local const $ADSTYPE_PRINTABLE_STRING = 4 Local const $ADSTYPE_NUMERIC_STRING = 5 Local const $ADSTYPE_BOOLEAN = 6 Local const $ADSTYPE_INTEGER = 7 Local const $ADSTYPE_OCTET_STRING = 8 Local const $ADSTYPE_UTC_TIME = 9 Local const $ADSTYPE_LARGE_INTEGER = 10 Local const $ADSTYPE_PROV_SPECIFIC = 11 Local const $ADSTYPE_OBJECT_CLASS = 12 Local const $ADSTYPE_CASEIGNORE_LIST = 13 Local const $ADSTYPE_OCTET_LIST = 14 Local const $ADSTYPE_PATH = 15 Local const $ADSTYPE_POSTALADDRESS = 16 Local const $ADSTYPE_TIMESTAMP = 17 Local const $ADSTYPE_BACKLINK = 18 Local const $ADSTYPE_TYPEDNAME = 19 Local const $ADSTYPE_HOLD = 20 Local const $ADSTYPE_NETADDRESS = 21 Local const $ADSTYPE_REPLICAPOINTER = 22 Local const $ADSTYPE_FAXNUMBER = 23 Local const $ADSTYPE_EMAIL = 24 Local const $ADSTYPE_NT_SECURITY_DESCRIPTOR = 25 Local const $ADSTYPE_UNKNOWN = 26 Local const $ADSTYPE_DN_WITH_BINARY = 27 Local const $ADSTYPE_DN_WITH_STRING = 28 $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $object & ");ADsPath;subtree" $objRecordSet = $objConnection.Execute ($strQuery); Retrieve the FQDN for the logged on user $ldap_entry = $objRecordSet.fields (0).value If $ldap_entry = "" Then ; Object doesn't exist Return EndIf $oObject = ObjGet($ldap_entry); Retrieve the COM Object for the logged on user $props = $oObject.GetInfo() $NumberOfDataObjects = $oObject.PropertyCount() For $i = 0 To $NumberOfDataObjects - 1 $item = $oObject.Item($i) $propentry = $oObject.GetPropertyItem($item.Name, $ADSTYPE_UNKNOWN) If IsObj($propentry) = 0 Then MsgBox(0,"property (kein objekt)", $item.Name) Else For $v In $propentry.Values If $item.ADsType = $ADSTYPE_CASE_IGNORE_STRING Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.CaseIgnoreString) ElseIf $item.ADsType = $ADSTYPE_INTEGER Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.Integer) ElseIf $item.ADsType = $ADSTYPE_LARGE_INTEGER Then If $item.Name = "pwdLastSet" Or $item.Name = "accountExpires" or $item.Name = "lastLogonTimestamp" Or $item.Name = "badPasswordTime" Or $item.Name = "lastLogon" Then _ArrayAdd($localObjectProps,$item.Name & "||" & _DateAdd("s", Int(LargeInt2Double($v.LargeInteger.LowPart,$v.LargeInteger.HighPart) / (10000000) ), "1601/01/01 00:00:00") ) Else _ArrayAdd($localObjectProps,$item.Name & "||" & LargeInt2Double($v.LargeInteger.LowPart,$v.LargeInteger.HighPart)) EndIf ElseIf $item.ADsType = $ADSTYPE_OCTET_STRING Then _ArrayAdd($localObjectProps,$item.Name & "||" & OctetToHexStr($v.OctetString)) ElseIf $item.ADsType = $ADSTYPE_DN_STRING Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.DNString) ElseIf $item.ADsType = $ADSTYPE_UTC_TIME Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.UTCTime) ElseIf $item.ADsType = $ADSTYPE_BOOLEAN Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.Boolean) ElseIf $item.ADsType = $ADSTYPE_NT_SECURITY_DESCRIPTOR Then _ArrayAdd($localObjectProps,$item.Name & "||" & $v.SecurityDescriptor) Else ;~ MsgBox(0,"type ist",$item.ADsType & "||" & $item.Name) EndIf Next EndIf Next $oObject = 0 $localObjectProps[0] = UBound($localObjectProps) -1 Return $localObjectProps EndFunc ;==>_ADGetObjectProperties Func LargeInt2Double($Low,$High) Local $result Local $resLow Local $resHigh If $Low < 0 Then $resLow = 2 ^ 32 + $Low Else $resLow = $Low EndIf If $High < 0 Then $resHigh = 2 ^ 32 + $High Else $resHigh = $High EndIf $result = $resLow + $resHigh * 2 ^ 32 Return $result EndFunc Func OctetToHexStr($var_octet) Local $Return Local $stringmid Local $ASC Local $HEX Dim $n $Return = "" For $n = 1 To BinaryLen($var_octet);StringLen($var_octet) $stringmid = BinaryMid($var_octet, $n, 1);StringMid($var_octet, $n, 1) $ASC = Asc($stringmid) $HEX = Hex($ASC) MsgBox(0,"oct",$stringmid & " | " & $ASC & " | " & $HEX) $Return = $Return & StringRight("0" & $HEX, 2) Next Return $Return EndFunc ; _ADObjectExists ; Takes an object name (SamAccountName without leading 'CN=') ; Returns 1 if the object exists in the tree, 0 otherwise Func _ADObjectExists($object) Local $strQuery Local $objRecordSet $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $object & ");ADsPath;subtree" $objRecordSet = $ObjConnection.Execute ($strQuery) ; Retrieve the FQDN for the group, if it exists If $objRecordSet.RecordCount = 1 Then $objRecordSet = 0 Return 1 Else $objRecordSet = 0 Return 0 EndIf EndFunc ;==>_ADObjectExists ; _ADDoError : Error event handler for COM errors. This is global so will pick up errors from your program if you include this library Func _ADDoError() Local $HexNumber = Hex($oMyError.number, 8) If $HexNumber = 80020009 Then SetError(3) Return EndIf If $HexNumber = "8007203A" Then SetError(4) Return EndIf MsgBox(262144, "", "COM Error !" & @CRLF & @CRLF & _ "ErrorNumber " & @TAB & ": " & $HexNumber & @CRLF & _ "WinDescription " & @TAB & ": " & $oMyError.windescription & @CRLF & _ "LineNumber " & @TAB & ": " & $oMyError.scriptline) Select Case $oMyError.windescription = "Access is denied." $objConnection.Close ("Active Directory Provider") $objConnection.Open ("Active Directory Provider") SetError(2) Case 1 SetError(1) EndSelect EndFunc ;==>_ADDoError ; here is the call to get the props $Properties = _ADGetObjectProperties("nekes") _ArrayDisplay($Properties) Edited October 23, 2007 by Sundance Link to comment Share on other sites More sharing options...
ptrex Posted October 23, 2007 Share Posted October 23, 2007 @SundanceThe OctetToHexStr function on VBS uses Byte Arrays as return values.I just logged a bug report about this. And the current status is that AU3 does not support this datatype (yet) ?! you can check the status here : Byte Arrays Return valuesregardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 23, 2007 Share Posted October 23, 2007 Thx for the info ptrex! Gonna check it. I'am also trying to use a dll structure but had no luck yet... greets Sundance Link to comment Share on other sites More sharing options...
ptrex Posted October 23, 2007 Share Posted October 23, 2007 @Sundance I can't play around with your script because you don't post the whole stuff. So I can't test if there is bypass solution. Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 23, 2007 Share Posted October 23, 2007 (edited) Oh really? Mmmhhh.Gonna try that codesnipped on my own. One moment...@SundanceI can't play around with your script because you don't post the whole stuff.So I can't test if there is bypass solution.Regards,ptrexSorry forgott the first part of the UDF.. i changed the code snipped from above... Edited October 23, 2007 by Sundance Link to comment Share on other sites More sharing options...
ptrex Posted October 23, 2007 Share Posted October 23, 2007 @Sundance When I ran it there where some indefunced functiosns and undeclared vars Errors coming up ? regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 23, 2007 Share Posted October 23, 2007 I run the above code from a single au3 and it goes without erros. I did change the code minutes ago.. Have you got it? Link to comment Share on other sites More sharing options...
Sundance Posted October 23, 2007 Share Posted October 23, 2007 Here is the au3 file :-)ReadOctetValueFromAD.au3 Link to comment Share on other sites More sharing options...
ptrex Posted October 24, 2007 Share Posted October 24, 2007 @sundance Can you also post the original VBScript "ReadOctetValue" function. Thanks ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Sundance Posted October 24, 2007 Share Posted October 24, 2007 (edited) Here is a function which does a convert from the byte array to a 'readable' hex-string '_________________________________________________________________[ OctetToHexStr ]__________ 'Function to convert OctetString (byte array) to a hexadecimal string. ' Function OctetToHexStr(var_octet) Dim n OctetToHexStr = "" For n = 1 To lenb(var_octet) OctetToHexStr = OctetToHexStr & Right("0" & Hex(ascb(midb(var_octet, n, 1))), 2) Next End Function You see it uses the binary functions which won't function under AutoIt @sundance Can you also post the original VBScript "ReadOctetValue" function. Thanks ptrex Edited October 24, 2007 by Sundance Link to comment Share on other sites More sharing options...
ptrex Posted October 24, 2007 Share Posted October 24, 2007 (edited) @SundanceI see that you haven't declared any Constant for Octet in your script ?Const $ADSTYPE_OCTET_STRING = 8Maybe this is bringing any light in the Octet problem :Octet StringIt's in German too. (Meine Deutsche Sprache is noch nicht so gut !!)I hope this can help.regardsptrex Edited October 24, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New 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