Quantcast
Viewing all articles
Browse latest Browse all 8156

.NET 4.5 - weird behavior of WindowsPrincipal.Current

Here's my code:


var b = WindowsPrincipal.Current.IsInRole(@"TEST\YYY Setup Group");
var ba = WindowsPrincipal.Current.IsInRole(@"BUILTIN\Administrators");
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal wPrincipal = new WindowsPrincipal(id);
bool st = wPrincipal.IsInRole(@"TEST\YYY Setup Group");
bool sta = wPrincipal.IsInRole(@"BUILTIN\Administrators");

My current user is not an administrator but a member of local admins (he was assigned there via Local Users and Computers) and domain group TEST\YYY Setup Groups. Why do I getb = false, ba = false, but st = true and sta = false?



Viewing all articles
Browse latest Browse all 8156


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>