Window Form Security Question

G

Guest

I am trying to set a buttons visibility on a C# Windows Application - form.
If the user who is logged onto the computer - running the app (on the clients
computer) is a member of a particluar active directory group, then I want the
button visible, otherwise it should be invisible...

I have attempted to do this, but my code always results in the user not
being in the group - which is false because I know that I am in the group!
Please help!

WindowsIdentity ident = WindowsIdentity.GetCurrent();
WindowsPrincipal user = new WindowsPrincipal(ident);

string username = ident.Groups.ToString(); // get the correct clients
domain\username
bool isingroup = user.IsInRole("Domain\\Group"); // this always shows false
- even when I know it is true...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top