c# - Enable/Disable AD user with LDAP -
is possible enable (or disable) user in active directory ldap command?
and also, possible doing c#?
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
Post a Comment