Jump to content
Sign in to follow this  

erease attribute contents from AD

Recommended Posts


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)

#include <file.au3>
#include <GUIConstants.au3>
#include <GUIListView.au3>
While 1
   If $msg = $APPLY Then
      If $NAME="" or GUICtrlRead($USER)="" Then
            $usr = ObjGet("LDAP://"&$TST)
            $usr.employeeID = String($NUID2)
      $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!")
Func GUI()
   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

Thanks for your help

Share this post

Link to post
Share on other sites

the function that I use to erease are:


$usr = ObjGet("LDAP://"&$TST)

$usr.PutEx ($ADS_PROPERTY_CLEAR, "employeeID", 0)


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.