Moin Jungs,
benötige Hilfe sowie verbesserungs Vorschläge.
Ich habe die Telefonnummer,Faxnummer, Sowie die Mobilfunknummer mit hilfe meiner Funktion func _wrong_chars_in_phonenumber überprüft das Funktioniert auch. Jetzt ist es so das ich 3 Möglichkeiten habe in der Funktion Mobilfunknummer sowie Homenummer funktioner das abscheichern der Nummer nicht richtig.
3 Fälle:
1. Error Buchstaben oder Sonderzeichen
=> Meldung in die Statusbar
2. Er scheidet die Null Vorne weg
3. Er Speichert es leer ab.
Wie bekomme ich das am Sinnvollsten hin ?
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
;--------------INCLUD ANFANG ----------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AD.au3>
#Include <Array.au3>
#include <GuiStatusBar.au3>
;--------------INCLUD ENDE ----------------------
Global $SDNSDomain, $SHostServer, $SConfiguration, $SPassword, $SUserId, $aTEMP , $status, $statusleiste , $templeer
[/autoit][autoit][/autoit][autoit]; Username+Passwort fuer Domainadmin
$SUserID = ""
$SPassword = ""
; Open Connection to the Active Directory
_AD_Open()
$SDNSDomain = $sAD_DNSDomain
$SHostServer = $sAD_HostServer
$SConfiguration = $sAD_Configuration
_AD_Close()
; Open Connection to the Active Directory
If _AD_Open($SUserId, $SPassword, $SDNSDomain, $SHostServer, $SConfiguration) THEN
ElseIf @error <= 8 Then
MsgBox(16, "Adressbuch AD-Tool", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended)
Else
MsgBox(16, "Adressbuch AD-Tool", "The logon was not succcessful!" & @CRLF & @CRLF & "@error: " & @error & ", @extended: " & @extended & _
@CRLF & @CRLF & "Extended error information will be displayed")
Global $aError = _AD_GetLastADSIError()
_ArrayDisplay($aError)
EndIf
Global $sUser = @UserName
Global $displayname = _AD_GetObjectAttribute(@UserName, "displayName")
Global $mail = _AD_GetObjectAttribute(@UserName, "mail")
#Region ### START Koda GUI section ### Form=
Global $Form1_1 = GUICreate("Adressbuch AD-Tool", 447, 466, 299, 127)
GUISetFont(10, 400, 0, "Arial")
Global $name = GUICtrlCreateLabel("Name:", 8, 12, 120, 21)
Global $nameanzeige = GUICtrlCreateLabel(_AD_GetObjectAttribute(@UserName, "givenName") & " " & _AD_GetObjectAttribute(@UserName, "sn"), 170, 12, 259, 21)
Global $durchwahllabel = GUICtrlCreateLabel("Durchwahl:", 8, 44, 72, 21)
Global $durchwahltemp = GUICtrlCreateInput(_AD_GetObjectAttribute(@UserName, "telephoneNumber"), 170, 40, 259, 21)
GUICtrlSetLimit ($durchwahltemp,4)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
[/autoit][autoit][/autoit][autoit]Global $telefonnummerlabel = GUICtrlCreateLabel("Telefonnummer:", 8, 76, 112, 21)
Global $homenrtemp = GUICtrlCreateInput(_AD_GetObjectAttribute(@UserName, "homePhone"), 170, 72, 259, 21)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $faxdurchwahllabel = GUICtrlCreateLabel("FAX-Durchwahl:", 8, 110, 104, 21)
Global $faxdurchwahltemp = GUICtrlCreateInput(_AD_GetObjectAttribute(@UserName, "facsimileTelephoneNumber"), 170, 104, 259, 21)
GUICtrlSetLimit ($faxdurchwahltemp,4)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $Mobilfunknummerlabel = GUICtrlCreateLabel("Mobilfunknummer:", 8, 140, 112, 21)
Global $mobilfunknummertemp = GUICtrlCreateInput(_AD_GetObjectAttribute(@UserName, "mobile"), 170, 136, 259, 21)
GUICtrlSetLimit ($mobilfunknummertemp,13)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $bueronummerlabel = GUICtrlCreateLabel("Raumnummer:", 8, 172, 88, 21)
Global $raumnummertemp = GUICtrlCreateInput(_AD_GetObjectAttribute(@UserName, "physicalDeliveryOfficeName"), 170, 168, 60, 21)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
[/autoit][autoit][/autoit][autoit];Hier werden die 4 Schaltflächen erstellt sowie die Labels für die Statuszeile
Global $BOK = GUICtrlCreateButton("Speichern", 136, 200, 73, 33, $BS_ICON)
Global $Anzeige = GUICtrlCreateButton("Anzeige", 24, 200, 73, 33, $BS_ICON)
Global $BCancel = GUICtrlCreateButton("Schließen", 256, 200, 73, 33, $BS_ICON)
Global $Copyright = GUICtrlCreateLabel("Copyright by LichtBlick AG", 144, 360, 161, 20)
Global $Softwarename = GUICtrlCreateLabel("LichtBlick Adressbuch AD-Tool", 96, 384, 243, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
Global $Version = GUICtrlCreateLabel("Version: 1.0", 176, 408, 74, 20)
$status = _GUICtrlStatusBar_Create($Form1_1)
_GUICtrlStatusBar_SetText($status)
_GUICtrlStatusBar_SetBkColor($status,0xFF0000)
Global $Pic1 = GUICtrlCreatePic("G:\Allg.Informationen, Formulare, Vorlagen\Vorlagen\LB_Logo\Logo Farbe 72.jpg", 0, 240, 444, 113, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;--------------ARRAY Anfang ----------------------
GLOBAL $array_attribute[11][3]
$array_attribute[0][0] = "company"
$array_attribute[1][0] = "streetAddress"
$array_attribute[2][0] = "postalCode"
$array_attribute[3][0] = "l"
$array_attribute[4][0] = "title"
$array_attribute[5][0] = "info"
$array_attribute[6][0] = "telephoneNumber"
$array_attribute[7][0] = "homePhone"
$array_attribute[8][0] = "facsimileTelephoneNumber"
$array_attribute[9][0] = "pager"
$array_attribute[10][0] = "mobile"
$array_attribute[0][1] = _AD_GetObjectAttribute(@UserName, "company")
$array_attribute[1][1] = _AD_GetObjectAttribute(@UserName, "streetAddress")
$array_attribute[2][1] = _AD_GetObjectAttribute(@UserName, "postalCode")
$array_attribute[3][1] = _AD_GetObjectAttribute(@UserName, "l")
$array_attribute[4][1] = _AD_GetObjectAttribute(@UserName, "title")
$array_attribute[5][1] = _AD_GetObjectAttribute(@UserName, "info")
$array_attribute[6][1] = _AD_GetObjectAttribute(@UserName, "telephoneNumber")
$array_attribute[7][1] = _AD_GetObjectAttribute(@UserName, "homePhone")
$array_attribute[8][1] = _AD_GetObjectAttribute(@UserName, "facsimileTelephoneNumber")
$array_attribute[9][1] = _AD_GetObjectAttribute(@UserName, "pager")
$array_attribute[10][1] = _AD_GetObjectAttribute(@UserName, "mobile")
$array_attribute[0][2] = _AD_GetObjectAttribute(@UserName, "company")
$array_attribute[1][2] = _AD_GetObjectAttribute(@UserName, "streetAddress")
$array_attribute[2][2] = _AD_GetObjectAttribute(@UserName, "postalCode")
$array_attribute[3][2] = _AD_GetObjectAttribute(@UserName, "l")
$array_attribute[4][2] = _AD_GetObjectAttribute(@UserName, "title")
$array_attribute[5][2] = _AD_GetObjectAttribute(@UserName, "info")
$array_attribute[6][2] = _AD_GetObjectAttribute(@UserName, "telephoneNumber")
$array_attribute[7][2] = _AD_GetObjectAttribute(@UserName, "homePhone")
$array_attribute[8][2] = _AD_GetObjectAttribute(@UserName, "facsimileTelephoneNumber")
$array_attribute[9][2] = _AD_GetObjectAttribute(@UserName, "pager")
$array_attribute[10][2] = _AD_GetObjectAttribute(@UserName, "mobile")
;--------------ARRAY ENDE ----------------------
[/autoit][autoit][/autoit][autoit];------Überprüfung der Rufnummern------------------------------------------
func _wrong_chars_in_phonenumber($text)
local $test_string = $text
[/autoit][autoit][/autoit][autoit]$test_string = StringReplace($test_string, "0", "")
$test_string = StringReplace($test_string, "1", "")
$test_string = StringReplace($test_string, "2", "")
$test_string = StringReplace($test_string, "3", "")
$test_string = StringReplace($test_string, "4", "")
$test_string = StringReplace($test_string, "5", "")
$test_string = StringReplace($test_string, "6", "")
$test_string = StringReplace($test_string, "7", "")
$test_string = StringReplace($test_string, "8", "")
$test_string = StringReplace($test_string, "9", "")
if $test_string<>"" THEN
RETURN TRUE
ELSE
RETURN FALSE
EndIf
endfunc
;--------------------------------------------------------
;Func changetelefondurchwahl
;EndFunc
[/autoit][autoit][/autoit][autoit]Func _DisplayError($message)
GUICtrlSetBkColor($statusleiste,0xFF0000)
GUICtrlSetColor($statusleiste,0x000000)
GUICtrlSetData($statusleiste,$message)
EndFunc
While 1
Global $nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $BCancel
Exit
Case $BOK
[/autoit][autoit][/autoit][autoit]If Not IsDeclared("iMsgBoxAnswer") Then Global $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_ICONEXCLAMATION,"LichtBlick Adressbuch AD-Tool","Möchten Sie die am Benutzer vorgenommenen Änderungen Speichern ?",5)
Select
Case $iMsgBoxAnswer = $IDYES
;Für die Durchwahl
$array_attribute[6][2] = GUICtrlRead($durchwahltemp)
IF $array_attribute[6][1] <> $array_attribute[6][2] THEN
IF _wrong_chars_in_phonenumber($array_attribute[6][2]) THEN
GUICtrlSetBkColor($durchwahltemp,0xFF0000)
_GUICtrlStatusBar_SetText($status,"Bitte im Feld Durchwahl nur Zahlen eintragen Beispiel: 1337")
ELSE
IF $array_attribute[6][2] = "" Then
$templeer = ""
_AD_ModifyAttribute($sUser, "telephoneNumber", $templeer)
Else
global $temp2 = "+49 (0)40 /6360 -"
_AD_ModifyAttribute($sUser, "telephoneNumber", $array_attribute[6][2])
$array_attribute[7][2] = $temp2 & $array_attribute[6][2]
_AD_ModifyAttribute($sUser, "homePhone", $array_attribute[7][2])
MsgBox(64, "Fehlermeldung", "mit string")
EndIf
ENDIF
EndIf
;Für die Homenummer
Global $internationvorwahl = "+49"
$array_attribute[7][2] = GUICtrlRead($homenrtemp)
IF $array_attribute[7][1] <> $array_attribute[7][2] THEN
IF _wrong_chars_in_phonenumber($array_attribute[7][2]) THEN
GUICtrlSetBkColor($homenrtemp,0xFF0000)
_GUICtrlStatusBar_SetText($status,"Bitte im Feld Telef nur Zahlen eintragen Beispiel: 2130")
Else
IF stringleft($array_attribute[7][2],1) = 0 THEN
$array_attribute[7][2] = stringtrimleft($array_attribute[7][2],1)
$templeer = ""
If $array_attribute[7][2] == $templeer THEN
_GUICtrlStatusBar_SetText($status,"Wenn Leer")
_AD_ModifyAttribute($sUser, "homePhone", $templeer)
EndIf
$array_attribute[7][2] = $internationvorwahl & $array_attribute[7][2]
_AD_ModifyAttribute($sUser, "homePhone", $array_attribute[7][2])
Else
$array_attribute[7][2] = $internationvorwahl & $array_attribute[7][2]
_AD_ModifyAttribute($sUser, "homePhone", $array_attribute[7][2])
EndIf
EndIf
ENDIF
;Für die Faxdurchwahl
$array_attribute[8][2] = GUICtrlRead($faxdurchwahltemp)
IF $array_attribute[8][1] <> $array_attribute[8][2] THEN
IF _wrong_chars_in_phonenumber($array_attribute[8][2]) THEN
GUICtrlSetBkColor($faxdurchwahltemp,0xFF0000)
_GUICtrlStatusBar_SetText($status,"Bitte im Feld Faxdurchwahl nur Zahlen eintragen Beispiel: 2130")
ELSE
Global $temp3 = "+49 (0)40 /6360 -"
global $faxtempnummer1 = $temp3 & $array_attribute[8][2]
_AD_ModifyAttribute($sUser, "facsimileTelephoneNumber", $faxtempnummer1)
ENDIF
ENDIF
;Für die Mobilfunknummer
Global $vorwahlint = "+49"
$array_attribute[10][2] = GUICtrlRead($mobilfunknummertemp)
IF $array_attribute[10][1] <> $array_attribute[10][2] THEN
IF _wrong_chars_in_phonenumber($array_attribute[10][2]) THEN
MsgBox(64, "Fehlermeldung", "Bitte im Feld Mobilfunknummer nur Zahlen eintragen Beispiel: 017640203481")
ELSE
IF stringleft($array_attribute[10][2],1) = 0 THEN
$array_attribute[10][2] = stringtrimleft($array_attribute[10][2],1)
$templeer =""
IF $array_attribute[10][2] == $templeer THEN
_AD_ModifyAttribute($sUser, "mobile", $templeer)
ENDIF
ELSE
$array_attribute[10][2] = $vorwahlint & $array_attribute[10][2]
_AD_ModifyAttribute($sUser, "mobile", $array_attribute[10][2])
ENDIF
ENDIF
ENDIF
;Für die Raumnummer
Global $roomnummber = GUICtrlRead($raumnummertemp)
IF $roomnummber = "" THEN
$templeer =""
_AD_ModifyAttribute($sUser, "physicalDeliveryOfficeName", $templeer)
ELSE
_AD_ModifyAttribute($sUser, "physicalDeliveryOfficeName", $roomnummber)
ENDIF
Case $iMsgBoxAnswer = $IDNO
Exit
Case $iMsgBoxAnswer = -1 ;Timeout
Exit
EndSelect
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit];--------------Funktion Adresse Fuellen Ende ----------------------
;MsgBox(64, "Adressbuch AD-Tool", "Daten für '" & $displayname & "' erfolgreich geändert ! ")
Case $Anzeige
MsgBox(64, "Anzeige für "& $displayname &"", @CRLF & "Titel( Akademischen Grad):" & @CRLF & $array_attribute[5][2] & @CRLF & "Windows Anmeldename:" & @CRLF &$sUser & @CRLF & "Durchwahl:" & @CRLF & $array_attribute[6][2] & @CRLF & "FAX-Druchwahl:" & @CRLF & $array_attribute[8][2] & @CRLF & "Mobilfunknummer:" & @CRLF & $array_attribute[10][2] & @CRLF & "Vollmacht:" & @CRLF & $array_attribute[9][2])
EndSwitch
WEnd
_AD_Close()