Hi,
I am displaying a folder if logged in user is not available in one of the SharePoint group called TestGroup.
For this I have written the code as below
But the problem is button is getting displayed to users who are in the TestGroup.
Please let me know if I am missing anything here.
privatevoid DisplayCreateSubFolder()
{
bool isMember = false;
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site =newSPSite(SPContext.Current.Site.Url))
{
SPWeb web = site.RootWeb;
string groupName = "TestGroup";
var spGroup = web.Groups[groupName];
isMember = web.IsCurrentUserMemberOfGroup(spGroup.ID);
if (isMember == true)
{
btn_CreateFolder_display.Visible =false;
}
else
{
btn_CreateFolder_display.Visible =true;
}
}
});
}
In the Page Load method I am calling the method as below
protectedvoid Page_Load(object sender,EventArgs e)
{
try
{
DisplayCreateSubFolder();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
Regards,
Sudheer
Thanks & Regards, Sudheer