LDAP Fehlerückmeldung

  • Hi,

    Habe das Problem, dass meine IF-Schleife bei einer Serverabfrage nicht mit der LDAP-Fehlerückmeldung klarkommt. Kriege immer nen ERROR:

    Spoiler anzeigen


    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Res_Fileversion=1
    #AutoIt3Wrapper_Res_Language=1031
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <SliderConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Klausurenmodus - Authentifizierung", 300, 200, 277, 397)

    GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
    $inputUser = GUICtrlCreateInput("", 24, 50, 193, 21)
    $inputPwd = GUICtrlCreateInput("", 24, 100, 193, 21, $ES_PASSWORD)

    $Label2 = GUICtrlCreateLabel("Benutzername", 24, 30, 82, 17)
    $Label3 = GUICtrlCreateLabel("Passwort", 24, 80, 56, 17)
    $Button1 = GUICtrlCreateButton("OK", 52, 152, 121, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $user = GUICtrlRead($inputUser)
    $pwd = GUICtrlRead($inputPwd)
    ldap()
    exit
    EndSwitch
    WEnd


    Func ldap()

    $strPfad = "LDAP://192.168.1.100/ou=Tim, dc=Ohburg, dc=BY, dc=de"
    $strAdmin = "cn= " & $user & ", cn=Users, dc=Ohburg, dc=BY, dc=de"

    $adsNamenraum = ObjGet("LDAP:")

    $adsContainer = $adsNamenraum.openDSObject($strPfad,$strAdmin,$pwd,0)


    if @exitCode 1 Then
    MsgBox (0, "fehler", "fehler bei eingabe")

    EndIf

    For $adsUser in $adsContainer

    $adsUser.accountDisabled=false
    $adsuser.setinfo


    Next

    $strPfad = "LDAP://192.168.1.100/ou=Klausuren, dc=Ohburg, dc=BY, dc=de"
    $strAdmin = "cn= " & $user &", cn=Users, dc=Ohburg, dc=BY, dc=de"

    $adsNamenraum = ObjGet("LDAP:")

    $adsContainer = $adsNamenraum.openDSObject($strPfad,$strAdmin,$pwd,0)

    For $adsUser in $adsContainer

    $adsUser.accountDisabled=true
    $adsuser.setinfo

    Next

    endFunc

  • Hey,

    funzt leider nicht. Kommt folgendes bei raus:

    [autoit]


    >"C:\Programme\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Dokumente und Einstellungen\Administrator\Desktop\test.au3"
    C:\Dokumente und Einstellungen\Administrator\Desktop\test.au3 (46) : ==> The requested action with this object has failed.:
    $adsContainer = $adsNamenraum.openDSObject($strPfad,$strAdmin,$pwd,0)
    $adsContainer = $adsNamenraum.openDSObject($strPfad,$strAdmin,$pwd,0)^ ERROR
    >Exit code: 1 Time: 11.372

    [/autoit]
  • Hallo tino-ks.

    Da Du in Deinem Skript COM-Objekte verwendest, solltest Du ein Fehlerbehandlung implementieren, um mögliche COM-Fehler zu behandeln. Schaue Dir hierfür das Kapitel "COM-Erweiterungen mit AutoIt" in der Hilfe an. Folgendes solltest Du Deinem Skript hinzufügen.

    [autoit]

    Global $g_oComErr = ObjEvent('AutoIt.Error', '_ComError')
    Func _ComError()
    Consolewrite($g_oComErr.Windescription & @Crlf)
    Return SetError(1)
    EndFunc ;==>_ComError

    [/autoit]
  • Mein Active Directory UDF (Download siehe Signatur) hat das alles bereits eingebaut.
    Die Funktionen um einen Account zu enablen/disablen sind bereits eingebaut.