|
I was running a report on our AD database and wanted to pull out certain information, namely the createTimeStamp property for all user accounts. I found that certain properties are Operational Attributes (aka Constructed Attributes). These are values that are not stored in Active Directory, and are therefore only calculated upon request. Additionally, you cannot get these values by performing a Get or GetEx method on them.
I was able to Google a method for retrieving these values and have converted it to a KiX function. Comments, observations, and improvements are welcome...
Break On CLS
$nul=SetOption("WrapAtEOL","On") $nul=SetOption("Explicit","On")
Dim $
fnGetOperationalAttribute("@USERID","createTimeStamp") ? @ERROR " | " @SERROR ? fnGetOperationalAttribute("@USERID","modifyTimeStamp") ? @ERROR " | " @SERROR ? fnGetOperationalAttribute("@USERID","whenCreated") ? @ERROR " | " @SERROR ?
Get $
Function fnGetOperationalAttribute($sNTName,$sProperty) Dim $strDNSDomain,$objCommand,$objConnection,$objRecordSet $strDNSDomain = "<LDAP://" + GetObject("LDAP://rootDSE").Get("defaultNamingContext") If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
$objCommand = CreateObject("ADODB.Command") $objConnection = CreateObject("ADODB.Connection") $objConnection.Provider = "ADsDSOObject" $objConnection.Open("Active Directory Provider") $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = $strDNSDomain + ">;(sAMAccountName=" + $sNTName + ");" + $sProperty + ";subtree" $objCommand.Properties("Page Size").value = 100 $objCommand.Properties("Timeout").value = 30 $objCommand.Properties("Searchscope").value = 2 $objCommand.Properties("Cache Results").value = False $objRecordSet = $objCommand.Execute If @ERROR<0 Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf $fnGetOperationalAttribute = "" + $objRecordSet.Fields($sProperty) EndFunction
[ 28. July 2003, 21:31: Message edited by: Chris S. ]
|