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

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -

shared memory - gstreamer shmsrc and shmsink with h264 data -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -