Questions tagged [windows-principal]

24 questions
31
votes
4 answers

How can I retrieve all the roles (groups) a user is a member of?

Is there a way to get a list of roles a Windows authenticated user is in, without explicitly checking by WindowsPrincipal.IsInRole method?
muratgu
  • 7,241
  • 3
  • 24
  • 26
22
votes
3 answers

How to create WindowsIdentity/WindowsPrincipal from username in DOMAIN\user format

The WindowsIdentity(string) constructor requires the username to be in username@domain.com format. But in my case I get the usernames from a DB in the old DOMAIN\user format (and then have to check their Windows role membership). What is the best…
Knaģis
  • 20,827
  • 7
  • 66
  • 80
17
votes
3 answers

What's the difference between retrieving WindowsPrincipal from WindowsIdentity and Thread.CurrentPrincipal?

I am trying to work out why attribute based security isn't working as I'd expect in WCF and I suspect it might have something to do with the following: AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); var identity = new…
Kofi Sarfo
  • 3,310
  • 6
  • 23
  • 24
12
votes
2 answers

MVC3 Windows Authentication override User.Identity

I am building a intranet application using MVC3 with a MSSQL backend. I have authentication and roles (through a custom roles provider) working properly. What I am trying to do now is overriding User.Identity to allow for items like…
7
votes
2 answers

IsInRole Getting New Security Token

I'm using WindowsPrincipal's IsInRole method to check group memberships in WPF and Winforms apps. I'm generating an identity token which can be for any AD user (not necessarily the user who's actually logged into the computer--depending on what I'm…
Jeff
  • 8,020
  • 34
  • 99
  • 157
6
votes
1 answer

How can I ensure that IsInRole checks are not using cached credentials

I have a WPF client that connects to a WCF service, and I want to lock down some of the functionality so that only certain users can perform certain actions. The WCF service impersonates the client user when executing service methods. The OS is…
Franchesca
  • 1,453
  • 17
  • 32
5
votes
1 answer

Why is WindowsPrincipal.IsInRole always returning false for the "Administrators" group?

My local user account is in the Administrators group, and I wanted to simply figure out how a windows forms project would determine if I'm in the administrators group. So, I started a windows forms project and tried the following: [STAThread] static…
Candide
  • 30,469
  • 8
  • 53
  • 60
5
votes
1 answer

WindowsPrincipal.IsInRole and universal vs. global active directory groups

Does anybody know how to make WindowsPrincipal.IsInRole("domain\role") work with active directory universal groups? Let's say the current user is a member of a group called Role in a domain called domain, and that the Role group is a Global group in…
sindre j
  • 4,404
  • 5
  • 31
  • 32
3
votes
1 answer

How can I determine if a user can runas admin?

When a user needs to enter their license key, we want to put it in HKLM if we can, and in HKCU if we cannot. If it is in HKLM then all users on the computer have the license without each having to enter it. We are an AddOn to Office so we run with…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
2
votes
0 answers

User.IsInRole(string) and multiple domains

I have been using WindowsPrincipal.IsInRole(string) to check whether a user has access to certain controller functions and all has been working well. A new requirement meant that users from a second domain needed to access the intranet site so…
Steve
  • 105
  • 8
2
votes
0 answers

Thread.CurrentPrincipal.Identity is changed after set in firstTime

I have a simple wpf sample(a window with a button) .I set Thread.CurrentPrincipal in constructor like: //my Window constructor public Window1(){ InitializeComponent(); Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); …
M.Azad
  • 3,673
  • 8
  • 47
  • 77
2
votes
1 answer

How To Get List Of Active Directory Domain Groups When Not Connected To Domain

At my company we have a custom HMI. This HMI can login using the domain of the computer if the user would like to. Here's the scenario we're currently trying to solve With user logged into Windows as a domain user, they login to the HMI using the…
1
vote
2 answers

How can I temporarily impersonate a user to open a file?

I would like to temporarily impersonate a domain user account to read in a file on a network drive from an ASP.NET site. I would rather not set up impersonation for the entire site or set up a mapped drive on the server.
Even Mien
  • 44,393
  • 43
  • 115
  • 119
1
vote
1 answer

Why does Vista report that my Windows account not being in Administrators Role?

Under Windows Vista, when I check whether my current user account is in Administrators role, I am getting a negative, as shown in the following picture. Can anyone tell me why I am not in the Administrators role? When I do the check if I am in…
dance2die
  • 35,807
  • 39
  • 131
  • 194
1
vote
1 answer

Get computer principal name with `GetUserNameEx`

I tried to get computer principal name of a service running as Network Service with the following code. BOOLEAN bError = GetUserNameEx(NameUserPrincipal, buffer, &buf_len); Since the domain name of my computer is Service-Windows@example.com, I…
Summer_More_More_Tea
  • 12,740
  • 12
  • 51
  • 83
1
2