Find what SharePoint groups a user belongs to.
From: Brian Hman (bhbhbh_at_community.nospam)
Date: 04/20/05
- Previous message: Greg M: "Group Policies across External Trust Relationship???"
- Next in thread: Rhett Gong [MSFT]: "RE: Find what SharePoint groups a user belongs to."
- Reply: Rhett Gong [MSFT]: "RE: Find what SharePoint groups a user belongs to."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 20 Apr 2005 14:11:03 -0700
Within a web part, I need to hide a particular control from certain users. We
have set up groups within sharepoint to determine if a user should see this
control.
I was using the following code to do that:
SPSite site = SPControl.GetContextSite(Context);
SPWeb web = site.OpenWeb();
SPUser user = web.CurrentUser;
//we did not make cross site groups. we do not have multiple sites.
SPRoleCollection groupRole = user.Roles;
Hashtable rolesForUser = new Hashtable();
foreach(SPRole role in groupRole)
{
rolesForUser.Add(role.Name, user.Name);
}
This works but only if the user is part of the Admin group along with their
other group memberships. How can I do the same thing and not make everyone
admin? I prefer not to use impersonation.
Thanks for your help
Brian Hman
- Previous message: Greg M: "Group Policies across External Trust Relationship???"
- Next in thread: Rhett Gong [MSFT]: "RE: Find what SharePoint groups a user belongs to."
- Reply: Rhett Gong [MSFT]: "RE: Find what SharePoint groups a user belongs to."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|