Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory not retrieving a Group that I'm a part of

Status
Not open for further replies.

spacedeveloper

Programmer
Aug 3, 2010
27
US
Hi All,

I'd really appreciate some help on this. It's got me a bit stumped.

I am trying to retrieve all of the Groups that I am a member of from Active Directory. The follow to pieces of code are ways that I am attempting to do this. It works very well with other users...but not for me! It used to!

Another thing is that when I do go into AD to check what groups I am a "Member Of"...I, indeed, DO belong to the very Group I am querying.

Method 1:

Code:
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(System.Web.HttpContext.Current.Request.LogonUserIdentity);
bool b = principal.IsInRole("SFRevenueAudit Access");

Method 2:

Code:
ArrayList groups = new ArrayList();
foreach (System.Security.Principal.IdentityReference group in HttpContext.Current.Request.LogonUserIdentity.Groups)
{
     groups.Add(group.Translate(typeof(System.Security.Principal.NTAccount)).ToString());
}
...then code to iterate through the Groups to find the one I am looking for...

Any help would be very much appreciate.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top