Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/2017 in all areas

  1. Or StringFormat("%02i\%02i\%04i" ,StringLeft($sR4, 2), StringMid($sR4, 3, 2), StringRight($sR4, 4))
    1 point
  2. Why do you have "http://site.ru/" in front of the filename? Jos
    1 point
  3. _ConvertSerialDateTime is not needed with the format you get (I mentioned the format in post #6). I can't test at the moment but you need to grab the left 4 characters for year, then 2 for month and again 2 for day and then re-arrange this 3 fields in the sequence you need.
    1 point
  4. Your case is even simpler. When you use Parameter = 1 then you get "19760703000000". This is YYYYMMDDHHMMSS. So either use Stringformat, String* functions or a RegExp to format the string to your liking.
    1 point
  5. No. If you check the wiki you will find a script that translates the internal dates you get from _Excel_RangeRead into the date format you require.
    1 point
  6. The value 3 reads the displayed/formatted value. Unfortunately MS only supports to read a single cell with this parameter. All other values return the internal representation of the date. Please check the wiki for a detailed description of how Excel stores dates.
    1 point
  7. mikell

    [Solved] list view

    You might try _GUICtrlListView_SetColumnWidth
    1 point
  8. Why not just use the Array for example ControlSend("[CLASS:MGUIWin]", "", "Edit2", $aArray[$i][1] & ',' & $aArray[$i][2] & @CR)
    1 point
  9. Thank you! Didn't realize that's how the function worked.
    1 point
  10. Melba23

    StringRegExp help

    faustf, I did not realise that the "?" was a required search string. That character is a valid PCRE token (meaning that something might not exist) thus we need to escape the search string so that the RegEx realises that all characters are literal. Using the file you posted this finds the "?" without problem: #include <MsgBoxConstants.au3> ; Read file into array $aLines = FileReadToArray("faustf.txt") ; Set required string to find $sTarget = "?" ; Now look for the string in the file and return the line number For $i = 0 To UBound($aLines) - 1 ; Now look for a line which matches the target ; - using the ^ $ anchors means that the other lines containing the string do NOT match ; - Using \Q...\E forcesall characters int eh sting to be interpreted literally If StringRegExp($aLines[$i], "^\Q" & $sTarget & "\E$") Then ; And we need to add 1 to the index to get the line number MsgBox($MB_SYSTEMMODAL, "Found it!", $sTarget & " is on line " & $i + 1) EndIf Next M23
    1 point
  11. From a support perspective I can say that of the 50 or so networks I encountered over the last 12 months only a handful were using this. That being said, I believe (like all UDF additions) it comes down to the level of effort for you to add it. If it is something you can add without tearing your hair out I think it has value; even if it will only serve 10% of users.
    1 point
  12. I was able to reduce execution time of _AD_GetObjectProperties. I query about 3500 users. The following script runs 161 seconds with the current function and 36 seconds with the new one: #include <AD.au3> _AD_Open() Global $iTimer = TimerInit() $aArray = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(name=*))", 2, "samaccountname,name", "") For $i=1 to $aArray[0][0] $aExpires = _AD_GetObjectPropertiesEX($aArray[$i][0], "accountexpires") Next ConsoleWrite(TimerDiff($iTimer) & @CRLF) _AD_Close() New function (named: _AD_GetobjectPropertiesEX): ; #FUNCTION# ==================================================================================================================== ; Name...........: _AD_GetObjectProperties ; Description ...: Returns a two-dimensional array of all or selected properties and their values of an object in readable form. ; Syntax.........: _AD_GetObjectProperties([$vObject = @UserName[, $sProperties = ""[, $bSort = True]]]) ; Parameters ....: $vObject - Optional: SamAccountName, FQDN or ADSPath of the object to retrieve properties from (e.g. computer, user, group ...) (default = @Username) ; |Can be of type object as well. Useful to get properties for a schema or configuration object (see _AD_ListRootDSEAttributes) ; $sProperties - Optional: Comma separated list of properties to return (default = "" = return all properties) ; $bSort - Optional: True specifies that the array will be sorted on property name (default = True) ; Return values .: Success - Returns a one based two-dimensional array with all properties and their values of an object in readable form ; Failure - "" or property name, sets @error to: ; |1 - $vObject could not be found ; |2 - No values for the specified property. The property in error is returned as the function result ; |3 - Error retrieving $vObject. @Extended is set to the error returned by LDAP ; Author ........: Sundance ; Modified.......: water ; Remarks .......: Dates are returned in format: YYYY/MM/DD HH:MM:SS local time of the calling user (AD stores all dates in UTC - Universal Time Coordinated) ; Exception: AD internal dates like "whenCreated", "whenChanged" and "dSCorePropagationData". They are returned as UTC ; NT Security Descriptors are returned as: Control:nn, Group:Domain\Group, Owner:Domain\Group, Revision:nn ; No error is returned if there are properties in $sProperties that are not available for the selected object ;+ ; Properties are returned in alphabetical order. If $sProperties is set to "samaccountname,displayname" the returned array will contain ; displayname as the first and samaccountname as the second row. ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/index.php?showtopic=49627&view=findpost&p=422402, http://msdn.microsoft.com/en-us/library/ms675090(VS.85).aspx ; Example .......: Yes ; =============================================================================================================================== Func _AD_GetObjectPropertiesEx($vObject = @UserName, $sProperties = "", $bSort = True) Local $aObjectProperties[1000][2], $oObject Local $oProperty, $oPropertyEntry, $oValue, $iPropertyRecord = 0, $xAD_Dummy ; Data Type Mapping between Active Directory and LDAP ; http://msdn.microsoft.com/en-us/library/aa772375(VS.85).aspx Local Const $ADSTYPE_DN_STRING = 1 Local Const $ADSTYPE_CASE_IGNORE_STRING = 3 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_NT_SECURITY_DESCRIPTOR = 25 Local Const $ADSTYPE_UNKNOWN = 26 Local $aSAMAccountType[12][2] = [["DOMAIN_OBJECT", 0x0], ["GROUP_OBJECT", 0x10000000], ["NON_SECURITY_GROUP_OBJECT", 0x10000001], _ ["ALIAS_OBJECT", 0x20000000], ["NON_SECURITY_ALIAS_OBJECT", 0x20000001], ["USER_OBJECT", 0x30000000], ["NORMAL_USER_ACCOUNT", 0x30000000], _ ["MACHINE_ACCOUNT", 0x30000001], ["TRUST_ACCOUNT", 0x30000002], ["APP_BASIC_GROUP", 0x40000000], ["APP_QUERY_GROUP", 0x40000001], _ ["ACCOUNT_TYPE_MAX", 0x7fffffff]] Local $aUAC[21][2] = [[0x00000001, "SCRIPT"], [0x00000002, "ACCOUNTDISABLE"], [0x00000008, "HOMEDIR_REQUIRED"], [0x00000010, "LOCKOUT"], [0x00000020, "PASSWD_NOTREQD"], _ [0x00000040, "PASSWD_CANT_CHANGE"], [0x00000080, "ENCRYPTED_TEXT_PASSWORD_ALLOWED"], [0x00000100, "TEMP_DUPLICATE_ACCOUNT"], [0x00000200, "NORMAL_ACCOUNT"], _ [0x00000800, "INTERDOMAIN_TRUST_ACCOUNT"], [0x00001000, "WORKSTATION_TRUST_ACCOUNT"], [0x00002000, "SERVER_TRUST_ACCOUNT"], [0x00010000, "DONT_EXPIRE_PASSWD"], _ [0x00020000, "MNS_LOGON_ACCOUNT"], [0x00040000, "SMARTCARD_REQUIRED"], [0x00080000, "TRUSTED_FOR_DELEGATION"], [0x00100000, "NOT_DELEGATED"], _ [0x00200000, "USE_DES_KEY_ONLY"], [0x00400000, "DONT_REQUIRE_PREAUTH"], [0x00800000, "PASSWORD_EXPIRED"], [0x01000000, "TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION"]] If Not IsObj($vObject) Then If StringLeft($vObject, 7) <> "LDAP://" Then ; No ADsPath If _AD_ObjectExists($vObject) = 0 Then Return SetError(1, 0, "") Local $sProperty = "sAMAccountName" If StringMid($vObject, 3, 1) = "=" Then $sProperty = "distinguishedName"; FQDN provided $__oAD_Command.CommandText = "<LDAP://" & $sAD_HostServer & "/" & $sAD_DNSDomain & ">;(" & $sProperty & "=" & $vObject & ");ADsPath;subtree" Local $oRecordSet = $__oAD_Command.Execute ; Retrieve the ADsPath for the object If @error Or Not IsObj($oRecordSet) Then Return SetError(3, @error, "") $vObject = $oRecordSet.fields(0).Value EndIf $oObject = __AD_ObjGet($vObject) ; Retrieve the COM Object Else $oObject = $vObject EndIf If $sProperties = "" Then $oObject.GetInfo() ; Refresh values of all properties in the property cache of the ADSI object Else Local $aProperties = StringSplit($sProperties, ",", $STR_NOCOUNT) $oObject.GetInfoEX($aProperties, 0) ; Refresh values of the selected properties in the property cache of the ADSI object EndIf Local $iPropertyCount = $oObject.PropertyCount() For $iCurrentProperty = 0 To $iPropertyCount - 1 $oProperty = $oObject.Item($iCurrentProperty) $oPropertyEntry = $oObject.GetPropertyItem($oProperty.Name, $ADSTYPE_UNKNOWN) $sPropertyName = $oProperty.Name If Not IsObj($oPropertyEntry) Then Return SetError(2, 0, $sPropertyName) For $vPropertyValue In $oPropertyEntry.Values $iPropertyRecord = $iPropertyRecord + 1 $aObjectProperties[$iPropertyRecord][0] = $sPropertyName Switch $oProperty.ADsType Case $ADSTYPE_CASE_IGNORE_STRING $aObjectProperties[$iPropertyRecord][1] = $vPropertyValue.CaseIgnoreString Case $ADSTYPE_INTEGER If $sPropertyName = "sAMAccountType" Then For $iCount4 = 0 To UBound($aSAMAccountType) - 1 If $vPropertyValue.Integer = $aSAMAccountType[$iCount4][1] Then $aObjectProperties[$iPropertyRecord][1] = $aSAMAccountType[$iCount4][0] ExitLoop EndIf Next ElseIf $sPropertyName = "userAccountControl" Then $aObjectProperties[$iPropertyRecord][1] = $vPropertyValue.Integer & " = " For $iCount4 = 0 To UBound($aUAC) - 1 If BitAND($vPropertyValue.Integer, $aUAC[$iCount4][0]) = $aUAC[$iCount4][0] Then $aObjectProperties[$iPropertyRecord][1] &= $aUAC[$iCount4][1] & " - " EndIf Next If StringRight($aObjectProperties[$iPropertyRecord][1], 3) = " - " Then $aObjectProperties[$iPropertyRecord][1] = StringTrimRight($aObjectProperties[$iPropertyRecord][1], 3) Else $aObjectProperties[$iPropertyRecord][1] = $vPropertyValue.Integer EndIf Case $ADSTYPE_LARGE_INTEGER If $sPropertyName = "pwdLastSet" Or $sPropertyName = "accountExpires" Or $sPropertyName = "lastLogonTimestamp" Or $sPropertyName = "badPasswordTime" Or $sPropertyName = "lastLogon" Or $sPropertyName = "lockoutTime" Then If $vPropertyValue.LargeInteger.LowPart = 0 And $vPropertyValue.LargeInteger.HighPart = 0 Then $aObjectProperties[$iPropertyRecord][1] = "1601/01/01 00:00:00" Else Local $sTemp = DllStructCreate("dword low;dword high") DllStructSetData($sTemp, "Low", $vPropertyValue.LargeInteger.LowPart) DllStructSetData($sTemp, "High", $vPropertyValue.LargeInteger.HighPart) Local $sTemp2 = _Date_Time_FileTimeToSystemTime(DllStructGetPtr($sTemp)) Local $sTemp3 = _Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($sTemp2)) $aObjectProperties[$iPropertyRecord][1] = _Date_Time_SystemTimeToDateTimeStr($sTemp3, 1) EndIf Else $aObjectProperties[$iPropertyRecord][1] = __AD_LargeInt2Double($vPropertyValue.LargeInteger.LowPart, $vPropertyValue.LargeInteger.HighPart) EndIf Case $ADSTYPE_OCTET_STRING $xAD_Dummy = DllStructCreate("byte[56]") DllStructSetData($xAD_Dummy, 1, $vPropertyValue.OctetString) ; objectSID etc. See: http://msdn.microsoft.com/en-us/library/aa379597(VS.85).aspx ; objectGUID etc. See: http://www.autoitscript.com/forum/index.php?showtopic=106163&view=findpost&p=767558 If _Security__IsValidSid(DllStructGetPtr($xAD_Dummy)) Then $aObjectProperties[$iPropertyRecord][1] = _Security__SidToStringSid(DllStructGetPtr($xAD_Dummy)) ; SID Else $aObjectProperties[$iPropertyRecord][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy)) ; GUID EndIf Case $ADSTYPE_DN_STRING $aObjectProperties[$iPropertyRecord][1] = $vPropertyValue.DNString Case $ADSTYPE_UTC_TIME $aObjectProperties[$iPropertyRecord][1] = StringRegExpReplace($vPropertyValue.UTCTime, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6") ; YYYY/MM/DD HH:MM:SS Case $ADSTYPE_BOOLEAN If $vPropertyValue.Boolean = 0 Then $aObjectProperties[$iPropertyRecord][1] = "False" Else $aObjectProperties[$iPropertyRecord][1] = "True" EndIf Case $ADSTYPE_NT_SECURITY_DESCRIPTOR $oValue = $vPropertyValue.SecurityDescriptor $aObjectProperties[$iPropertyRecord][1] = "Control:" & $oValue.Control & ", " & _ "Group:" & $oValue.Group & ", " & _ "Owner:" & $oValue.Owner & ", " & _ "Revision:" & $oValue.Revision Case Else $aObjectProperties[$iPropertyRecord][1] = "Has the unknown ADsType: " & $oProperty.ADsType EndSwitch Next Next ReDim $aObjectProperties[$iPropertyRecord + 1][2] $aObjectProperties[0][0] = $iPropertyRecord $aObjectProperties[0][1] = 2 If $bSort And $iPropertyRecord > 1 Then _ArraySort($aObjectProperties, 0, 1) ; Only sort if flag is set and array contains > 1 records Return $aObjectProperties EndFunc ;==>_AD_GetObjectPropertiesEx Edit: The new function is included in the new version 1.4.4.0 of the UDF.
    1 point
×
×
  • Create New...