Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Check is user belongs to group

$
0
0

Good day,

I am checking if the current user belongs to a certain group and it is always returning false. An excerpt of my code is below. THis is running in a Visual Webpart.

bool isApprover = false;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
                    {
                        using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                        {
                                SPGroup group = web.Groups["Custom Approvers"];
                                bool flag = web.IsCurrentUserMemberOfGroup(group.ID);
                                if (flag)
                                {
                                    isApprover = true;
                                }

                            //}
                        }
                    }
                });

Please assist.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



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