Beiträge von gmmg
-
-
wenn d1 <> "dom1" oder d1 <> "dom2" oder "d2" <> "logondnsdomain" dann ende.
ich hab jetzt einfach das @LogonDNSDomain weggelassen!gruß gmmg
-
das heißt ja, das ich nur noch 2 variablen per "OR" verknüpfung abfragen kann! wobei es in den vorigen versionen anders war!
gruß gmmg
-
@fgreenhorn
die ersten beiden fälle treffen aber nicht zu und in der vorletzten version hat es noch funktioniert!
gruß gmmg
-
hallo Xenobiologist
die abfrage mit einem or geht ja, deshalb wundert es mich, dass wenn ich mehrere logon domains abfrage, das script dann trotzdem in den Exit zweig geht!
[autoit]If @LogonDomain <> "xxx" Or @LogonDNSDomain <> "xxx.INT" Then EXIT
[/autoit]werd das aber dann nochmal genauer testen! hab nur gleich nen meeting

gruß gmmg
-
hallo zusammen,
ich möchte folgendes abfragen!
[autoit]
bisher hat die abfrage so immer funktioniert, mit der neuen version funktioniert die "or" abfrage nicht mehr und er beendet das script!If @LogonDomain <> "xxx" Or @LogonDomain <> "xxxx.INT" Or @LogonDNSDomain <> "xxx.INT" Then EXIT
[/autoit]gruß gmmg
-
hallo water,
ok, das werd ich so mal testen!
heut war ich auf der CEBIT in Hannover
viele grüsse
gmmg
-
@IT-Mensch
du kannst auch nocht die domain abfragen
[autoit]If @LogonDomain <> "xxxx" Or @LogonDNSDomain <> "xxxx.INT" Then EXIT
[/autoit]oder einen ipadress bereich!
gruß gmmg
-
kann der user der damit arbeiten soll, überhaupt eine exe decompilieren?
oder machst du dir da jetzt nur sorgen, weil es nicht in den it richtlinien steht, das er keine fremdsoftware nutzen darf!
ein normaler user, der nicht viel mit it, programmierung zu tun hat, würde auf solch einen gedanken nicht kommen!gruß gmmg
-
water hab mir fast sowas gedacht!

so, ich teste gleich mal ....
ergebnis dauer ca. 50 sek!
ich muss aber unseren sitename übergeben
[autoit]Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],"unser Sitename",$aDC)
[/autoit]
wenn ich den auch dynamisch übergebe, dann dauert das script wieder ewigkeiten!
ich nehme an, weil es nicht in jeder site einen dc gibt!macht es sinn, anhand der abfrage des @logonservers, das array" $aDC" zu bereinigen und nur den eintrag zu nehmen?
gruß und danke
gmmg -
habe das jetzt mal ausgelesen und statisch den dc wie folgt übergeben!
[autoit]
[/autoit]
;------list dc's----
Local $aDC = _AD_ListDomainControllers()
;_ArrayDisplay($aDC, "Active Directory Functions - Example 1 - All Domain Controllers, distinguished name, DNS host name, and the site name")
;-------------------
;scriptabschnitt _AD_GetLastLoginDate
Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],"sitename",$aDC[14][0])hier macht er aber keine abfrage mehr bzw. das array "_ArrayDisplay($alogin)" ist leer ! und es kommt auch kein fehler!
ohne den 3 parameter wird das array gefüllt!gruß gmmg
-
hallo water,
1. das ganze script ohne die Lastlogin funktion läuft 36 sekunden
2. 2400 user werden in 34 sites abgefragt
3. 19 domänencontroller, dabei hat aber nicht jede site einen dc, weil es standorte mit nur 2-3 user gibt!gruß gmmg
-
das war die änderung mit _AD_ListDomainControllers in der AD.au3
Beitrag:
Active Directory Funktionen - Neues Beispielskriptich häng mal das ganze script an, die daten werden in ein excel sheet geschrieben!
vielleicht ist da nen geschwindigkeitsproblem!Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <Excel.au3>
#Include <File.au3>
#include <AD.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#Include <Date.au3>;ldap attribute -> http://www.selfadsi.de/user-attributes-w2k3.htm
[/autoit] [autoit][/autoit] [autoit]
; excel book erstellen
; user nach sites eintragen
; user nach company eintragen
; user gesamt nach sites eintragenDIM $oMyRet, $oMyError, $oExcel, $saveas, $sOU
[/autoit] [autoit][/autoit] [autoit]
Local $avArray[1] ,$avArray_01[1], $alogin[1], $aObjects , $aObjects_01, $avArray_10[1], $sValue
_AD_Open();auslesen der einzelnen OU's
[/autoit] [autoit][/autoit] [autoit]
$aOUs = _AD_GetObjectsInOU($sOU, "(objectCategory=organizationalUnit)", 1, "name") ;"distinguishedName")
If @error > 0 Then
MsgBox(64, "Active Directory Functions - Example 2", "No OUs could be found")
Else
;_ArrayDisplay($aOUs, "Active Directory Functions - Example 2 - All OUs starting with: '" & $sOU & "'")
EndIf
;---------------------------------
;_ArrayDelete($aOUs, 0) ;löscht 1 eintrag aus dem array
_ArraySort($aOUs)
;_ArrayDisplay($aOUs, "AD all Site OUs!");erstelle excel dokument
[/autoit] [autoit][/autoit] [autoit]
Local $oExcel = _ExcelBookNew() ;Create new book, make it visible
_ExcelSheetDelete($oExcel, "Sheet1") ;Delete Sheet by string name of SheetName
_ExcelSheetDelete($oExcel, "Sheet2") ;Delete Sheet by string name of SheetName
_ExcelSheetDelete($oExcel, "Sheet3") ;Delete Sheet by string name of SheetName
_ExcelSheetDelete($oExcel, "Tabelle1") ;Delete Sheet by string name of SheetName
_ExcelSheetDelete($oExcel, "Tabelle2") ;Delete Sheet by string name of SheetName
;-----------------------
Sleep(1000)For $x = 1 to $aOUs[0]
[/autoit] [autoit][/autoit] [autoit]
;(lastlogontimestamp<=129171852000000000)
;$aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=xxx,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(userAccountControl=512))", 2, "sAMAccountName,mail,company")
;$aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=xxx,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(|(userAccountControl=512)(msExchHideFromAddressLists="")(msExchHideFromAddressLists=TRUE)(userAccountControl=66048)))", 2, "sAMAccountName,department,company")
$aObjects = _AD_GetObjectsInOU("OU=User,OU=Site,DC=xxx,DC=int", "(&(objectcategory=person)(objectclass=user)(mail=*)(|(userAccountControl=512)(msExchHideFromAddressLists="")(msExchHideFromAddressLists=False)(userAccountControl=66048)))", 2, "sAMAccountName,department,company")
$aObjects_01 = $aObjects
_ArrayDisplay($aObjects_01);---------------LastLoginDate -----------------------------
[/autoit] [autoit][/autoit] [autoit]
For $i = 1 To $aObjects[0][0]
Local $result
Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],"erf01")
;Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],$aOUs[$x])
$result = StringLeft($iLLDate,
$yyyy = StringTrimRight($result,4)
$mm = StringTrimLeft($result,4)
$mm = StringTrimRight($mm,2)
$dd = StringTrimLeft($result,6)
$YYYY_MM_DD = $yyyy & "/" & $mm & "/" & $dd & " 00:00:00"
;MsgBox(0, "Leftmost 3 characters are:", $result & " " & $YYYY_MM_DD)
$DateDiff = _DateDiff('D', $YYYY_MM_DD, _NowCalc()) ;"YYYY/MM/DD[ HH:MM:SS]"
If $DateDiff > 60 Then
;MsgBox(0, "Älter 60 Tage:",$aOUs[$x] & " " & $aObjects[$i][0] & " " & $DateDiff & " " & $result)
_ArrayAdd($alogin, $aObjects[$i][0] & ";" & $DateDiff)EndIf
[/autoit] [autoit][/autoit] [autoit]
Next
_ArrayDisplay($alogin)
;-------------------------------------------------------If @error > 0 Then
[/autoit] [autoit][/autoit] [autoit]
;MsgBox(64, "", "Nichts gefunden Error: " & @error)
Else
;$bench = TimerInit() ; laufzeittest
;--user pro company in site zählen-----
$Array_05 = _GetUsers_Summary($aObjects_01) ;dieses Array enthält die Ergebnisse
$Array_06 = _GetUsers_Summary1($aObjects_01) ;dieses Array enthält die Ergebnisse
;If Not @error Then _ArrayDisplay($Array_05)
;If Not @error Then _ArrayDisplay($avArray_10)
;ConsoleWrite(Round(TimerDiff($bench) / 1000, 4) & " s" & @CRLF) ; laufzeittest ausgabe
;--------------------------------------
_ExcelSheetAddNew($oExcel, $aOUs[$x])
_ExcelWriteCell($oExcel, "User", 1, 1) ;Write to the Cell
_ExcelWriteCell($oExcel, "Department", 1, 2) ;Write to the Cell
_ExcelWriteCell($oExcel, "Company", 1, 3) ;Write to the Cell
$oExcel.Columns("A:A").ColumnWidth = "30" ;setze spaltenbreite
$oExcel.Columns("B:B").ColumnWidth = "50" ;setze spaltenbreite
$oExcel.Columns("C:C").ColumnWidth = "50" ;setze spaltenbreite
$oExcel.Range("A1:C1") .Font.Bold = TRUE ; setze schriftgrad
$oExcel.Range("A1:C1") .Font.Size = 14 ; setze schriftgröße
;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
$oExcel.Range("A1:C1") .Interior.ColorIndex = 43 ; setze Farbe
;$oExcel.Name = $aOUs[$x]For $i = 1 To $aObjects[0][0]
[/autoit] [autoit][/autoit] [autoit]
;MsgBox(0,"", $aObjects[$i][0])
#CS
;---------------LastLoginDate -----------------------------
Local $result
Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],"erf01")
;Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],$aOUs[$x])
$result = StringLeft($iLLDate,
$yyyy = StringTrimRight($result,4)
$mm = StringTrimLeft($result,4)
$mm = StringTrimRight($mm,2)
$dd = StringTrimLeft($result,6)
$YYYY_MM_DD = $yyyy & "/" & $mm & "/" & $dd & " 00:00:00"
;MsgBox(0, "Leftmost 3 characters are:", $result & " " & $YYYY_MM_DD)
$DateDiff = _DateDiff('D', $YYYY_MM_DD, _NowCalc()) ;"YYYY/MM/DD[ HH:MM:SS]"
If $DateDiff > 60 Then MsgBox(0, "Älter 60 Tage:",$aOUs[$x] & " " & $aObjects[$i][0] & " " & $DateDiff & " " & $result)
;-------------------------------------------------------
#CE
$zeile = $i + 1
IF $aObjects[0][0] <> "" Then
_ExcelWriteCell($oExcel, $aObjects[$i][0], $zeile, 1)
_ExcelWriteCell($oExcel, $aObjects[$i][1], $zeile, 2)
_ExcelWriteCell($oExcel, $aObjects[$i][2], $zeile, 3)
$oExcel.Range("A"& $zeile &":C"& $zeile) .Interior.ColorIndex = 27 ; setze Farbe
$oExcel.Range("A1:C"&$zeile).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
EndIf
Next
_ArrayAdd($avArray, $aOUs[$x] & ";" & $aObjects[0][0])
_ExcelWriteCell($oExcel, $aObjects[0][0], $zeile + 2, 2)
_ExcelWriteCell($oExcel, "All USER " & $aOUs[$x] & ":", $zeile + 2, 1)$oExcel.Range("A"& $zeile +2 &":B"& $zeile+2) .Interior.ColorIndex = 27 ; setze Farbe
[/autoit] [autoit][/autoit] [autoit]
$oExcel.Range("A1:B"&$zeile +2).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
$oExcel.Range("A"& $zeile +2 &":B"& $zeile+2) .Font.Bold = TRUE ; setze schriftgrad;-------schreibe user pro company in excelsheet -------
[/autoit] [autoit][/autoit] [autoit]
For $i = 0 To UBound($Array_05) - 1
;MsgBox(0,"", $Array_05[$i][0] & " " &$Array_05[$i][1])
IF $Array_05[$i][0] = "" Then
;MsgBox(0,"",$Array_05[$i][1])
_ExcelWriteCell($oExcel,"No Department", $zeile + 4 + $i, 1)
Else
_ExcelWriteCell($oExcel, $Array_05[$i][0], $zeile + 4 + $i, 1)
EndIf
_ExcelWriteCell($oExcel, $Array_05[$i][1], $zeile + 4 + $i, 2)
$oExcel.Range("A"& $zeile + 4 + $i &":B"& $zeile + 4 + $i) .Interior.ColorIndex = 27 ; setze Farbe
$oExcel.Range("A1:B"&$zeile + 4 + $i).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
$oExcel.Range("A"& $zeile + 4 +$i &":B"& $zeile + 4 +$i) .Font.Bold = TRUE ; setze schriftgrad
IF $aObjects[0][0] <> "" Then _ArrayAdd($avArray_01, $aOUs[$x] & ";" & $Array_05[$i][0] & ";" & $Array_05[$i][1]) ; füge daten in array für YGesamt
Next
EndIf
If $aObjects <> "" Then _ArrayAdd($avArray_01, ";;")
;-------------------------------------------------------
Next;_ArrayDisplay($avArray_01)
[/autoit] [autoit][/autoit] [autoit]_AD_Close()
[/autoit] [autoit][/autoit] [autoit]_ExcelSheetDelete($oExcel, "Tabelle3") ;Delete Sheet by string name of SheetName
[/autoit] [autoit][/autoit] [autoit]
_ExcelSheetAddNew($oExcel, "YGesamt")
_ExcelSheetAddNew($oExcel, "ZGesamt")
_ExcelSheetOrderByName($oExcel, 0);_ArrayDisplay($avArray)
[/autoit] [autoit][/autoit] [autoit]#Region ZGesamt
[/autoit] [autoit][/autoit] [autoit]
;---------ZGesamt-------------------------
_ExcelWriteCell($oExcel, "Site", 1, 1) ;Write to the Cell
_ExcelWriteCell($oExcel, "Anzahl User", 1, 2) ;Write to the Cell
_ExcelSheetActivate($oExcel, "ZGesamt")
$oExcel.Columns("A:A").ColumnWidth = "30" ;setze spaltenbreite
$oExcel.Columns("B:B").ColumnWidth = "50" ;setze spaltenbreite
$oExcel.Range("A1:B1") .Font.Bold = TRUE ; setze schriftgrad
$oExcel.Range("A1:B1") .Font.Size = 14 ; setze schriftgröße
;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
$oExcel.Range("A1:B1") .Interior.ColorIndex = 43 ; setze Farbe
;$oExcel.Name = $aOUs[$x]For $i = 1 To _ArrayMaxIndex($avArray, 0, 1)
[/autoit] [autoit][/autoit] [autoit]
;MsgBox(0,"", $avArray[$i])
$zeile_1 = $i + 1
$eintrag = StringSplit($avArray[$i], ";")
_ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 1)
_ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 2)
$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1) .Interior.ColorIndex = 27 ; setze Farbe
$oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
Next_ExcelWriteCell($oExcel, "=Summe(B2:B"& $zeile_1 ,$zeile_1 + 1 , 2) ;Write formula another way Uses A1 referencing, not R1C1
[/autoit] [autoit][/autoit] [autoit]
_ExcelWriteCell($oExcel, "All User",$zeile_1 + 1 , 1) ;Write formula another way Uses A1 referencing, not R1C1
; formatiert letzte Zeile
$oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Interior.ColorIndex = 27 ; setze Farbe
$oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1).Borders.LineStyle = 1 ; setze einen Rahmen um die Zellen
$oExcel.Range("A"& $zeile_1 +1 &":B"& $zeile_1 + 1) .Font.Bold = TRUE ; setze schriftgrad;---------Ende ZGesamt---------------------
[/autoit] [autoit][/autoit] [autoit]
#EndRegion ZGesamt
#Region YGesamt
;---------YGesamt--------------------------
_ExcelSheetActivate($oExcel, "YGesamt")
_ExcelWriteCell($oExcel, "Site", 1, 1) ;Write to the Cell
_ExcelWriteCell($oExcel, "Department", 1, 2) ;Write to the Cell
;_ExcelWriteCell($oExcel, "User", 1, 3) ;Write to the Cell
_ExcelSheetActivate($oExcel, "YGesamt")
$oExcel.Columns("A:A").ColumnWidth = "25" ;setze spaltenbreite
$oExcel.Columns("B:B").ColumnWidth = "30" ;setze spaltenbreite
;$oExcel.Columns("C:C").ColumnWidth = "20" ;setze spaltenbreite
$oExcel.Range("A1:B1") .Font.Bold = TRUE ; setze schriftgrad
$oExcel.Range("A1:B1") .Font.Size = 14 ; setze schriftgröße
;$oExcel.Range("A1:D1") .Font.Color = 0xffffff
$oExcel.Range("A1:B1") .Interior.ColorIndex = 43 ; setze Farbe
;$oExcel.Name = $aOUs[$x]For $i = 1 To _ArrayMaxIndex($avArray_10, 0, 1)
[/autoit] [autoit][/autoit] [autoit]
;IF $aObjects[0][0] <> "" Then
$zeile_1 = $i + 1
$eintrag = StringSplit($avArray_10[$i], ";")
_ExcelWriteCell($oExcel, $eintrag[1], $zeile_1, 1)
_ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 2)
;_ExcelWriteCell($oExcel, $eintrag[3], $zeile_1, 3)
If $eintrag[1] = "" Then
$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1).Interior.ColorIndex = 43 ; setze Farbe
_ExcelWriteCell($oExcel, $eintrag[2], $zeile_1, 3)
Else
$oExcel.Range("A"& $zeile_1 &":B"& $zeile_1).Interior.ColorIndex = 27 ; setze Farbe
EndIf
$oExcel.Range("A1:B"&$zeile_1).Borders.LineStyle = 1 ; setze einen Rahmen um die ZellenNext
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
;---------Ende YGesamt---------------------
#EndRegion ZGesamt;$saveas = "C:\User_in Sites"
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
;_ExcelBookSaveAs($oExcel, $saveas, "xls")
;_ExcelBookClose($oExcel, 1, 0);===============================================================================
[/autoit] [autoit][/autoit] [autoit]
; Function Name: _ExcelSheetOrderByName($oExcel, $iDesc=0)
; Description:: Order ExcelBook-Sheets by name ascending (default) or descending
; Parameter(s): $oExcel - Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()
; $iDesc - order descending on=1/off=0 (default)
; Requirement(s): #Include <Array.au3>
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0 and sets @error=1 - Specified object does not exist
; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
;===============================================================================
Func _ExcelSheetOrderByName($oExcel, $iDesc=0)
If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
If $iDesc <> 1 Then $iDesc = 0
Local $aList = _ExcelSheetList($oExcel)
_ArraySort($aList, $iDesc)
Local $pos = 1
For $i = 0 To UBound($aList) -1
If $i = 0 Then
_ExcelSheetMove($oExcel, $aList[$i], $pos, True)
Else
_ExcelSheetMove($oExcel, $aList[$i], $pos, False)
$pos += 1
EndIf
Next
Return 1
EndFuncFunc _GetUsers_Summary(ByRef $aObjects_01)
[/autoit] [autoit][/autoit] [autoit]
If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
_ArrayDelete($aObjects_01, 0)
If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
_ArrayDelete($aCompanies, 0)
_ArraySort($aCompanies)Local $aResult[UBound($aCompanies)][2]
[/autoit] [autoit][/autoit] [autoit]
For $i = 0 To UBound($aCompanies) - 1
$aResult[$i][0] = $aCompanies[$i]
NextFor $i = 0 To UBound($aResult) - 1
[/autoit] [autoit][/autoit] [autoit]
;$aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
$aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 1)
$aResult[$i][1] = UBound($aTemp)
Next
Return $aResult
EndFunc ;==>_GetUsers_SummaryFunc _GetUsers_Summary1(ByRef $aObjects_01)
[/autoit] [autoit][/autoit] [autoit]
If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
_ArrayDelete($aObjects_01, 0)
If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
_ArrayDelete($aCompanies, 0)
_ArraySort($aCompanies)For $i = 0 To UBound($aCompanies) - 1
[/autoit] [autoit][/autoit] [autoit][/autoit]
_ArrayAdd($avArray_10,$aOUs[$x] & ";" & $aCompanies[$i])
Next
If $aObjects_01 <> "" Then _ArrayAdd($avArray_10, ";;")
EndFunc ;==>_GetUsers_Summaryvielleicht lässt sich hier einiges optimieren!
gruß gmmg
-
hallo water

es gibt an jedem standort einen dc! wobei das script jeweils immer nur von einem standord ausgeführt werden soll!
hier mal der abschnitt mit dem ich das ganze ausführe!
praktisch vergleiche ich die lastlogintime mit _nowcalc! wenn die tage im beispiel > 60 zeige mir die an oder schreibe die in eine array oder sonstwas!
[autoit]
[/autoit][autoit][/autoit][autoit]
;---------------LastLoginDate -----------------------------
For $i = 1 To $aObjects[0][0]
Local $result
Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],"sitename")
;Local $iLLDate = _AD_GetLastLoginDate($aObjects[$i][0],$aOUs[$x])
$result = StringLeft($iLLDate,
$yyyy = StringTrimRight($result,4)
$mm = StringTrimLeft($result,4)
$mm = StringTrimRight($mm,2)
$dd = StringTrimLeft($result,6)
$YYYY_MM_DD = $yyyy & "/" & $mm & "/" & $dd & " 00:00:00"
;MsgBox(0, "Leftmost 3 characters are:", $result & " " & $YYYY_MM_DD)
$DateDiff = _DateDiff('D', $YYYY_MM_DD, _NowCalc()) ;"YYYY/MM/DD[ HH:MM:SS]"
If $DateDiff > 60 Then
;MsgBox(0, "Älter 60 Tage:",$aOUs[$x] & " " & $aObjects[$i][0] & " " & $DateDiff & " " & $result)
_ArrayAdd($alogin, $aObjects[$i][0] & ";" & $DateDiff)EndIf
[/autoit][autoit][/autoit][autoit][/autoit]
Next
_ArrayDisplay($alogin)
;-------------------------------------------------------
gruß gmmg
-
Hallo Zusammen,
für eines meiner Scripte benötige ich den AD LastLoginTimeStamp!
Dieser ist ja in der AD.au3 dabei, aber sehr langsam!nun habe ich mir gedacht, ich frage diesen schon beim einlesen über "lastlogontimestamp" ab!
Spoiler anzeigen
[autoit]
[/autoit]
$aObjects = _AD_GetObjectsInOU("OU=User,OU="&$aOUs[$x]&",DC=xxx,DC=int", "(&(objectcategory=person)(objectclass=user)(lastlogontimestamp<=129171852000000000))", 2, "sAMAccountName,mail,company")wenn ich nun hier alle user haben möchte, die sich zum beispiel vor 60 tagen das letzte mal eingeloogt haben, muss ich mir die zahl bei lastlogontimestamp<=129171852000000000 generieren!
[autoit]
hierzu habe ich auf der inet seite http://www.selfadsi.de/deep-inside/mi…-attributes.htm eine Funktion gefunden, die zeigt, wie man ein Datum in einen Integer8 umwandelt.
diese möchte ich gern in autoit wandeln!
[/autoit] [autoit][/autoit] [autoit]
'zeigt den Integer8 Wert des aktuellen Datums+Uhrzeit...WScript.Echo DateToLargeIntegerString(Now)
[/autoit] [autoit][/autoit] [autoit]Function DateToLargeIntegerString(value)
[/autoit] [autoit][/autoit] [autoit]
'nimmt ein Datun+Uhrzeit und gibt den entsprechenden Microsoft LargeInteger Wert (Integer8) zurück'erst die lokale Zeitabweichung aus der Registry auslesen
[/autoit] [autoit][/autoit] [autoit]
Set sho = CreateObject("Wscript.Shell")
timeShiftValue = sho.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If IsArray(timeShiftValue) Then
timeShift = 0
For i = 0 To UBound(timeShiftValue)
timeShift = timeShift + (timeShiftValue(i) * 256^i)
Next
Else
timeShift = timeShiftValue
End If'die Zeit von lokaler Zeit in UTC umrechnen
[/autoit] [autoit][/autoit] [autoit]
value = DateAdd("n", timeShift, value)'wieviele Sekunden seit 1601 sind vergangen?
[/autoit] [autoit][/autoit] [autoit]
secs = DateDiff("s", #1/1/1601#, value)'in Nano-Sekunden umrechnen
[/autoit]
DateToLargeIntegerString = CStr(secs) & "0000000"
End Function
im englischen forum hab ich nur von lastlogintimestam in lesbares datumsfpormat gefunden!
http://www.autoitscript.com/forum/topic/86…ript-to-autoit/kann man diese funktion einfach umsetzen oder gibt es eventuell dafür schon eine lösung?
mein bisheriger versuch
[autoit]
[/autoit][autoit][/autoit][autoit]
#Include <Date.au3>;last logon timestamp
[/autoit][autoit][/autoit][autoit]$ll_datum = "01.01.2012 00:00:00"
[/autoit][autoit][/autoit][autoit]_DateToLargeIntegerString($ll_datum)
[/autoit][autoit][/autoit][autoit]Func _DateToLargeIntegerString($value)
[/autoit][autoit][/autoit][autoit]
;nimmt ein Datun+Uhrzeit und gibt den entsprechenden Microsoft LargeInteger Wert (Integer8) zurück;erst die lokale Zeitabweichung aus der Registry auslesen
[/autoit][autoit][/autoit][autoit]
;Set sho = CreateObject("Wscript.Shell")
$timeShiftValue = RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\","ActiveTimeBias")
MsgBox(0,"",$timeShiftValue)If IsArray($timeShiftValue) Then
[/autoit][autoit][/autoit][autoit]
$timeShift = 0
For $i = 0 To UBound($timeShiftValue)
$timeShift = $timeShift + ($timeShiftValue($i) * 256^$i)
Next
Else
$timeShift = $timeShiftValue
EndIf;die Zeit von lokaler Zeit in UTC umrechnen
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]
$value = _DateAdd("n", $timeShift, $value)
;_DateAdd($sType, $iValToAdd, $sDate);wieviele Sekunden seit 1601 sind vergangen?
[/autoit][autoit][/autoit][autoit]
$secs = _DateDiff("s", "#1/1/1601#", $value)
;_DateDiff($sType, $sStartDate, $sEndDate)MsgBox(0,"",$secs)
[/autoit][autoit][/autoit][autoit]
;in Nano-Sekunden umrechnen
$DateToLargeIntegerString = CStr($secs) & "0000000"EndFunc
[/autoit]gruß gmmg
-
@sedas
wie ist das bei einem mehrdimensionalen array?
leere zeilen müssen auch gezählt werden!mein array habe ich ja unten vorgegeben (dieses wird eigentlich aus dem Active Directory ausgelesen)
Update:
[autoit]
[/autoit]
alt: $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
neu: $aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 1)danke allen!
gruß gmmg

-
ich teste gerade die funktion schrittweise und finde den fehler nicht! zum einfachen testen, hab ich mal das array gleich mit angehangen!
bei _ArrayFindAll ist irgendwo der wurm drin
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <Array.au3>; array $aObjects_01
[/autoit] [autoit][/autoit] [autoit]
Local $aObjects_01[7][3]$aObjects_01[0][0] = "6"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[0][1] = "3"$aObjects_01[1][0] = "beyasa"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[1][1] = "Operation Management"
$aObjects_01[1][2] = "MC"$aObjects_01[2][0] = "beylch"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[2][1] = "Operation Management"
$aObjects_01[2][2] = "MC"$aObjects_01[3][0] = "beynha"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[3][1] = "Operation Management"
$aObjects_01[3][2] = "MC"$aObjects_01[4][0] = "beysal"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[4][1] = ""
$aObjects_01[4][2] = "MC"$aObjects_01[5][0] = "beysen"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[5][1] = "Reservation"
$aObjects_01[5][2] = "MC"$aObjects_01[6][0] = "beyshu"
[/autoit] [autoit][/autoit] [autoit]
$aObjects_01[6][1] = ""
$aObjects_01[6][2] = "MC"_ArrayDisplay($aObjects_01)
[/autoit] [autoit][/autoit] [autoit]_GetUsers_Summary($aObjects_01)
[/autoit] [autoit][/autoit] [autoit]Func _GetUsers_Summary(ByRef $aObjects_01)
[/autoit] [autoit][/autoit] [autoit]
If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
_ArrayDelete($aObjects_01, 0)
If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
_ArrayDelete($aCompanies, 0)
_ArraySort($aCompanies)Local $aResult[UBound($aCompanies)][2]
[/autoit] [autoit][/autoit] [autoit]
For $i = 0 To UBound($aCompanies) - 1
$aResult[$i][0] = $aCompanies[$i]
;MsgBox(0,"", $aResult[$i][0]) ; gibt mir die einzelnen $aCompanies aus
Next
_ArrayDisplay($aResult) ;gibt mir die einzelnen $aCompanies im array aus
;_ArrayDisplay($aObjects_01)For $i = 0 To UBound($aResult) - 1
[/autoit] [autoit][/autoit] [autoit][/autoit]
MsgBox(0,"", $aResult[$i][0])
$aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
MsgBox(0,"", $aTemp) ; ergebnis -1 , das heißt es gibt hier einen fehler
$aResult[$i][1] = UBound($aTemp)
Next
Return $aResult
EndFunc ;==>_GetUsers_SummaryautoBert kannst du hier helfen?
vielen dank im vorraus

gruß gmmg
-
hallo zusammen,
aus irgendeinem grund geht die funktion _GetUsers_Summary() nicht mehr!
[autoit]
ich habe folgenden array! hier möchte ich nun über die funktion _GetUsers_Summary() zählen, wie oft jeder eintrag z.b. Operation Management, Reservation vorkommt!
[/autoit]
; array $aObjects_01
[0]|6|3|
[1]|beyasa|Operation Management|MC
[2]|beylch|Operation Management|MC
[3]|beynha|Operation Management|MC
[4]|beysal||MC
[5]|beysen|Reservation|MC
[6]|beyshu||MCskript
Spoiler anzeigen
[autoit][/autoit] [autoit][/autoit] [autoit]$Array_ergebnis = _GetUsers_Summary($aObjects_01)
[/autoit] [autoit][/autoit] [autoit]
If Not @error Then _ArrayDisplay($Array_ergebnis)Func _GetUsers_Summary(ByRef $aObjects_01)
[/autoit]
If Not IsArray($aObjects_01) Then SetError(1, 0, 0)
_ArrayDelete($aObjects_01, 0)
If Not IsArray($aObjects_01) Then SetError(2, 0, 0)
Local $aCompanies = _ArrayUnique($aObjects_01, 2) ; prüfe feld xy
_ArrayDelete($aCompanies, 0)
_ArraySort($aCompanies)
Local $aResult[UBound($aCompanies)][2]
For $i = 0 To UBound($aCompanies) - 1
$aResult[$i][0] = $aCompanies[$i]
Next
For $i = 0 To UBound($aResult) - 1
$aTemp = _ArrayFindAll($aObjects_01, $aResult[$i][0], 0, 0, 0, 0, 2)
$aResult[$i][1] = UBound($aTemp)
Next
Return $aResult
EndFunc ;==>_GetUsers_Summarykann da mal bitte einer drüber schauen? die funktion zählt mir nicht mehr, wieviele gleiche einträge in spalte 2 jeweils vorhanden sind (siehe bild2)!
danke
gruß gmmg
-
-
versuche eben die funktion _AD_GetLastLoginDate zu benutzen!
in der AD_1.1.0_Functions bzw. AD_1.0.0_Functions bekomm ich folgenden fehler:
D:\Data\scripte\AD_1.1.0_Funktions\AD.au3 (1400) : ==> Error in expression.:
Local $sAD_DsServiceDN = $oAD_DCRootDSE.Get("dsServiceName")
Local $sAD_DsServiceDN = ^ ERRORSpoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <AD.au3>; Open Connection to the Active Directory
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
_AD_Open()
Global $result
;If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
; Get last login date for the current user
Global $iLLDate = _AD_GetLastLoginDate("username","sitename")
MsgBox(64, "Active Directory Functions - Example 1", "Last Login Date for User '" & @UserName & "'" & @CRLF & $iLLDate)
$result = StringLeft($iLLDate,
MsgBox(0, "Leftmost 3 characters are:", $result); Close Connection to the Active Directory
[/autoit]
_AD_Close()mit der Version AD_0.43_Funktions und früher geht es aber!
kannst du das prüfen?
danke
Gruß gmmg
