ter-pierre Posted January 27, 2006 Posted January 27, 2006 Hi guys. I needs to erese the contents of an attribute of an object from Active Directory. I have one script to fill this attribute, and desire to use this same script to empty this attribute. But if I inform an empty value the script dont change the attribute contents. above the code...(still testing... some trash may be foud) expandcollapse popup#include <file.au3> #include <GUIConstants.au3> #include <GUIListView.au3> Dim $msg,$APPLY,$NAME, $USER, $NUID, $USERNAME, $UID While 1 GUI() If $msg = $APPLY Then If $NAME="" or GUICtrlRead($USER)="" Then $NAME="" $NUID="" Else $SPLIT=StringSplit(GUICtrlRead($UID),"") $NUID2=String(GUICtrlRead($UID)) $usr = ObjGet("LDAP://"&$TST) $usr.employeeID = String($NUID2) $usr.SetInfo $NAME="" $NUID="" EndIf Else $objConnection = ObjCreate("ADODB.Connection") $objConnection.Open ("Provider=ADsDSOObject;") $objCommand = ObjCreate("ADODB.Command") $objCommand.ActiveConnection = $objConnection $objCommand.CommandText = "<LDAP://dc=test,dc=net>;(&(objectCategory=User)(samAccountName="&GUICtrlRead($USER)&"));SAmAccountName,DisplayName,employeeID,distinguishedName;subtree" $objRecordSet = $objCommand.Execute if $objRecordSet.RecordCount = 0 then MsgBox(0,"UID","Not Found!") $NAOME="" $NUID="" else $TST=$objRecordSet.Fields("distinguishedName").Value $USERNAME=$objRecordSet.Fields("DisplayName").Value $NOME=$objRecordSet.Fields("DisplayName").Value $NCPF=$objRecordSet.Fields("employeeID").Value EndIf $objConnection.Close() EndIf WEnd Func GUI() GUICreate("EID",450,200,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) GUICtrlCreateLabel("User", 10,35,40,20) GUICtrlCreateLabel("Name", 10,65,40,20) GUICtrlCreateLabel("EIDF", 10,95,40,20) $USER=GUICtrlCreateInput($USERNAME, 70,30,120,20) $NAME=GUICtrlCreateLabel ($NAME, 70,65,350,20) $EID=GUICtrlCreateInput ($NEID, 70,90,75,20) $CONSULT=GUICtrlCreateButton ("Consult", 10, 150, 60) $APPLY=GUICtrlCreateButton ("Apply", 80, 150, 60) $CANCEL=GUICtrlCreateButton ( "Cancel", 150, 150, 60) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $APPLY or $msg = $CONSULT Then ExitLoop If $msg = $CANCEL Then Exit Wend EndFunc Thanks for your help
ter-pierre Posted January 31, 2006 Author Posted January 31, 2006 the function that I use to erease are: Const $ADS_PROPERTY_CLEAR = 1 $usr = ObjGet("LDAP://"&$TST) $usr.PutEx ($ADS_PROPERTY_CLEAR, "employeeID", 0) $usr.SetInfo()
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now