Jump to content

JKFN

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by JKFN

  1. I fixed it myself and wrote how. And yes, it's tested. The main problem is in the func _AD_ObjectExists. ; #FUNCTION# ==================================================================================================================== ; Name...........: _AD_ObjectExists ; Description ...: Returns 1 if exactly one object exists for the given property in the local Active Directory Tree. ; Syntax.........: _AD_ObjectExists([$sObject = @UserName[, $sProperty = ""]]) ; Parameters ....: $sObject - [optional] Object (user, computer, group, OU) to check (default = @UserName) ; $sProperty - [optional] Property to check. If omitted the function tries to determine whether to use sAMAccountname or FQDN ; Return values .: Success - 1, Exactly one object exists for the given property in the local Active Directory Tree ; Failure - 0, sets @error to: ; |1 - No object found for the specified property ; |x - More than one object found for the specified property. x is the number of objects found ; Author ........: Jonathan Clelland ; Modified.......: water ; Remarks .......: Checking on a computer account requires a "$" (dollar) appended to the sAMAccountName. ; To check the existence of an OU use the FQDN of the OU as first parameter because an OU has no SamAccountName. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _AD_ObjectExists($sObject = @UserName, $sProperty = "") If $sObject = Default Then $sObject = @UserName If $sProperty = "" Or $sProperty = Default Then $sProperty = "samAccountName" If StringMid($sObject, 3, 1) = "=" Then $sProperty = "distinguishedName" EndIf If IsObj($__oAD_Command) Then $__oAD_Command.CommandText = "<LDAP://" & $sAD_HostServer & "/" & $sAD_DNSDomain & ">;(" & $sProperty & "=" & $sObject & ");ADsPath;subtree" Local $oRecordSet = $__oAD_Command.Execute ; Retrieve the ADsPath for the object, if it exists If IsObj($oRecordSet) Then If $oRecordSet.RecordCount = 1 Then Return 1 ElseIf $oRecordSet.RecordCount > 1 Then Return SetError($oRecordSet.RecordCount, 0, 0) Else Return SetError(1, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_AD_ObjectExists + The solution _AD_Close() see above.
  2. It's important? It happens sometimes. I turned on several thousand stations via WakeOnLan and then different things happen. 😀 The script runs on startup.
  3. I find bug. If the connection with AD ends between AD_Open and AD_ObjectExists, the script ends with an error: Variable must by of type "Object". In AD_Close missing: If IsObj($__oAD_Command) Then $__oAD_Connection.Close() + $__oAD_Command = 0 In AD_ObjectExists missing: If Not IsObj($__oAd_Command) Then Return SetError(1,0,0)
  4. But True return even in 32bit. Compiled in 3.3.8.1. My fix: ... If $aAD_ObjectProperties[$iCount3][0]='objectGUID' Then $aAD_ObjectProperties[$iCount3][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy)) ; GUID ...
  5. Yes, string "{70080EA1-9096-4541-8A4A-E86B9127BAB7}" is GUID, but function "_Security__IsValidSid(DllStructGetPtr($xAD_Dummy))" return True.
  6. Bug in _AD_GetObjectProperties() Example: _AD_GetObjectProperties($SAM,'objectGUID') where return value objectGUID is ValidSID (example: {70080EA1-9096-4541-8A4A-E86B9127BAB7} ) Func _AD_GetObjectProperties($sAD_Object = @UserName, $sAD_Properties = "") .... ElseIf $oAD_Item.ADsType = $ADSTYPE_OCTET_STRING Then $xAD_Dummy = DllStructCreate("byte[56]") DllStructSetData($xAD_Dummy, 1, $vAD_PropertyValue.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 $aAD_ObjectProperties[$iCount3][1] = _Security__SidToStringSid(DllStructGetPtr($xAD_Dummy)) ; SID Else $aAD_ObjectProperties[$iCount3][1] = _WinAPI_StringFromGUID(DllStructGetPtr($xAD_Dummy)) ; GUID EndIf ....
×
×
  • Create New...