c# - Enable/Disable AD user with LDAP -


is possible enable (or disable) user in active directory ldap command?

and also, possible doing c#?

i've looked here , here

thanks,

j

you can use principalcontext enable/ disable ad account. enable ad can this:

 private static void enableaduserusinguserprincipal(string username)      {        try     {                         principalcontext principalcontext = new principalcontext(contexttype.domain);          userprincipal userprincipal = userprincipal.findbyidentity                 (principalcontext, username);          userprincipal.enabled = true;          userprincipal.save();      }     catch (exception ex)     {         console.writeline(ex.message);     }  } 

to disable active directory can set userprincipal.enabled = false;


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -