PrincipalContext Domain access RRS feed

  • Question

  • User982203039 posted

    How can I check the current user (to see of they have access to AD to unlock a user) and use that user to unlock an account? If I hard code a username and password in the PrinipalContext it works fine. I just don't want to expose a password:


            public ActionResult Unlock(string user)
                PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
                // find a user
                UserPrincipal usr = UserPrincipal.FindByIdentity(ctx, user);
                if (usr != null)
                return RedirectToAction("Index");

    Monday, May 3, 2021 2:20 PM

All replies