Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IPrincipal principal = Thread.CurrentPrincipal;
- IIdentity identity = principal == null ? null : principal.Identity;
- string name = identity == null ? "" : identity.Name;
- Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
- string userName = "Fred"; // todo
- string[] roles = { "User", "Admin" }; // todo
- Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(userName), roles);
- string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement