User.IsInRole returning false

Posted by Curtis on Stack Overflow See other posts from Stack Overflow or by Curtis
Published on 2010-03-15T23:01:24Z Indexed on 2010/03/15 23:09 UTC
Read the original article Hit count: 721

Filed under:
|

My ASP.NET app is using windows authentication. If I run the following code:

        WindowsIdentity wi = (WindowsIdentity)User.Identity;
        foreach (IdentityReference r in wi.Groups)
        {
            ListBox1.Items.Add(r.Translate (typeof (NTAccount)).Value);
        }
        if (User.IsInRole ("Everyone"))
            Label1.Text = "Is in role";

The listbox will contain the name of every group the user belongs to. If I then call User.IsInRole, and pass in the name of any of those groups, I always get a false.

Can anyone tell me what I am doing wrong?

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about security