ListAdsiToTxt("MyDomain\MyGroup","@SCRIPTDIR\group.txt")
ListAdsiToTxt("MyDomain\MyUser","@SCRIPTDIR\user.txt")
ListAdsiToTxt("MyDomain\MyComputer$","@SCRIPTDIR\computer.txt")
Function ListAdsiToTxt($usr, $logf)
Global $log
Dim $cnusr, $usrnfo, $usrclas, $fso, $prop
$cnusr = TranslateName($usr)
$usrnfo = GetObject("LDAP://" + $cnusr)
$usrclas = GetObject($usrnfo.schema)
$fso = CreateObject("Scripting.FileSystemObject")
$log = $fso.OpenTextFile($logf, 8, 1)
$log.WriteLine("Mandatory Properties:")
$log.WriteLine("---------------------")
$log.WriteLine("")
For Each $prop in $usrclas.MandatoryProperties
If NOT Instr($prop,"-")
$=Execute("$$Type=VarTypeName($$usrnfo."+$prop+")")
$=Execute("$$Value=$$usrnfo."+$prop)
$s = ""
Select
Case $type = "Object"
WriteLog($prop,$type)
Case $type = "Variant[]"
WriteLog($prop,$type)
For Each $item in $value
WriteLog("*"+$prop,$type,$item)
Next
Case $type = "Byte[]"
$comma = ""
For $i=0 to Len($value)
$s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($value,$i,1))),2)
$comma = ","
Next
WriteLog($prop,$type,$s)
Case 1
WriteLog($prop,$type,$value)
EndSelect
Else
WriteLog($prop,"N/A")
EndIf
Next
$log.WriteLine("")
$log.WriteLine("Optional Properties:")
$log.WriteLine("--------------------")
$log.WriteLine("")
For Each $prop in $usrclas.OptionalProperties
If NOT Instr($prop,"-")
$= Execute("$$Type=VarTypeName($$usrnfo."+$prop+")")
$= Execute("$$Value=$$usrnfo."+$prop)
$s = ""
Select
Case $type = "Object"
$objDate = Integer8Date($value)
WriteLog($prop,$type,$objdate)
Case $type = "Variant[]"
WriteLog($prop,$type)
For Each $item in $value
WriteLog("*"+$prop,$type,$item)
Next
Case $type = "Byte[]"
$comma = ""
For $i=0 to Len($value)
$s=$s+$comma+Right("0"+DecToHex(Asc(SubStr($value,$i,1))),2)
$comma = ","
Next
WriteLog($prop,$type,$s)
Case 1
WriteLog($prop,$type,$value)
EndSelect
Else
WriteLog($prop,"N/A")
EndIf
Next
$log.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
$log.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case LEN($LineToWrite) >= 8 AND LEN($LineToWrite) < 16
$log.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case LEN($LineToWrite) >= 16 AND LEN($LineToWrite) < 24
$log.WriteLine($LineToWrite+Chr(9)+Chr(9)+Chr(9)+$sType+$sValue)
Case LEN($LineToWrite) >= 24 AND LEN($LineToWrite) < 32
$log.WriteLine($LineToWrite+Chr(9)+Chr(9)+$sType+$sValue)
Case LEN($LineToWrite) >= 32
$log.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