ListAdsiToTxt("DOMAIN\username","@SCRIPTDIR\username.txt")
Function ListAdsiToTxt($strADObject, $strLogFile)
Global $objLog
Dim $objCN, $objLDAP, $objLDAPSchema, $objFSO, $objProperty
$objCN = TranslateName($strADObject)
$objLDAP = GetObject("LDAP://" + $objCN)
$objLDAPSchema = GetObject($objLDAP.schema)
$objFSO = CreateObject("Scripting.FileSystemObject")
$objLog = $objFSO.OpenTextFile($strLogFile, 8, 1)
$objLog.WriteLine("Mandatory Properties:")
$objLog.WriteLine("---------------------")
$objLog.WriteLine("")
For Each $objProperty In $objLDAPSchema.MandatoryProperties
If NOT InStr($objProperty,"-")
$=Execute("$$strPropType=VarTypeName($$objLDAP."+$objProperty+")")
$=Execute("$$strPropValue=$$objLDAP."+$objProperty)
$s = ""
Select
Case $strPropType = "Object"
WriteLog($objProperty,$strPropType)
Case $strPropType = "Variant[]"
WriteLog($objProperty,$strPropType)
For Each $item In $strPropValue
WriteLog("*"+$objProperty,$strPropType,$item)
Next
Case $strPropType = "Byte[]"
$comma = ""
For $i=0 to Len($strPropValue)
$s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($strPropValue,$i,1))),2)
$comma = ","
Next
WriteLog($objProperty,$strPropType,$s)
Case 1
WriteLog($objProperty,$strPropType,$strPropValue)
EndSelect
Else
WriteLog($objProperty,"N/A")
EndIf
Next
$objLog.WriteLine("")
$objLog.WriteLine("Optional Properties:")
$objLog.WriteLine("--------------------")
$objLog.WriteLine("")
For Each $objProperty In $objLDAPSchema.OptionalProperties
If NOT InStr($objProperty,"-")
$= Execute("$$strPropType=VarTypeName($$objLDAP."+$objProperty+")")
$= Execute("$$strPropValue=$$objLDAP."+$objProperty)
$s = ""
Select
Case $strPropType = "Object"
$objDate = Integer8Date($strPropValue)
WriteLog($objProperty,$strPropType,$objdate)
Case $strPropType = "Variant[]"
WriteLog($objProperty,$strPropType)
For Each $item In $strPropValue
WriteLog("*"+$objProperty,$strPropType,$item)
Next
Case $strPropType = "Byte[]"
$comma = ""
For $i=0 to Len($strPropValue)
$s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($strPropValue,$i,1))),2)
$comma = ","
Next
WriteLog($objProperty,$strPropType,$s)
Case 1
WriteLog($objProperty,$strPropType,$strPropValue)
EndSelect
Else
WriteLog($objProperty,"N/A")
EndIf
Next
$objLog.Close
EndFunction
Function WriteLog($LineToWrite,$sType,Optional $sValue)
Select
Case Len($sType) < 9
$sType = $sType+Chr(9)+Chr(9)
Case Len($sType) >= 9
$sType = $sType+Chr(9)
Case 1
? "Other Type?"
EndSelect
Select
Case Len($LineToWrite) < 8
$objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case Len($LineToWrite) >= 8 AND Len($LineToWrite) < 16
$objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case Len($LineToWrite) >= 16 AND Len($LineToWrite) < 24
$objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case Len($LineToWrite) >= 24 AND Len($LineToWrite) < 32
$objLog.WriteLine($LineToWrite+Chr(9)+Chr(9)+$sType+$sValue)
Case Len($LineToWrite) >= 32
$objLog.WriteLine($LineToWrite+Chr(9)+$sType+$sValue)
Case 1
? "Other Len?"
EndSelect
EndFunction
Function TranslateName($NameToTranslate)
Dim $NameTranslate
$NameTranslate = CreateObject("NameTranslate")
$NameTranslate.Init(3,"")
$NameTranslate.Set(3,$NameToTranslate)
$TranslateName = $NameTranslate.Get(1)
EndFunction
Function Integer8Date($objDate,optional $lngBias)
Dim $lngHigh,$lngLow,$lngDate,$Pow,$l,$jdate,$lngYear,$lngMonth,$lngDay,$s,$m,$h
If NOT (VarType($objDate) & 9) Exit 87 EndIf
If VarType($lngBias)=0
$lngBias = Val(ReadValue("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\","ActiveTimeBias"))
If @ERROR Exit @ERROR EndIf
EndIf
$lngHigh = $objDate.HighPart
$lngLow = $objDate.LowPart
If $lngLow < 0 $lngHigh=$lngHigh+1 EndIf
If $lngHigh = 0 AND $lngLow = 0 $lngBias=0 EndIf
$Pow=2.0
For $l = 1 to 31 $Pow=2.0*$Pow Next
$lngDate = ((CDbl($lngHigh)*$Pow+$lngLow)/600000000-$lngBias)/1440
If $lngDate > 0
$jdate = 584389 + Fix($lngDate)
$lngYear = (100*(((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4))+
(100*($jdate+306)-25))/36525
$lngMonth = (5*(((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4)+
($jdate+306)-365*$lngYear-$lngYear/4)+456)/153
$lngDay = (((100*($jdate+306)-25)/3652425)-(((100*($jdate+306)-25)/3652425)/4)+
($jdate+306)-365*$lngYear-$lngYear/4)-(153*$lngMonth-457)/5
If $lngMonth>12 $lngYear=$lngYear+1 $lngMonth=$lngMonth-12 EndIf
$lngMonth = Right("0"+$lngMonth,2)
$lngDay = Right("0"+$lngDay,2)
$s = Fix(86400.0 * ($lngDate-Fix($lngDate)))
$m = $s / 60
$s = $s mod 60
$h = $m / 60
$m = $m mod 60
$Integer8Date=''+$lngYear+'/'+$lngMonth+'/'+$lngDay+' '+$h+':'+Right("0"+$m,2)+':'+Right("0"+$s,2)
EndIf
EndFunction