/// <summary>
/// isLoginUserInGroup
/// </summary>
/// <param name="group"></param>
/// <returns></returns>
public bool IsLogOnUserInGroup(string group)
{
var bUserIsInGroup = false;
try
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (var objSite = new SPSite(SPContext.Current.Site.Url))
{
using (var objWeb = objSite.OpenWeb())
{
SPGroup objGroup = SearchGroup(objWeb, group.Trim());
if (objGroup != null)
{
String sUserLoginName = LogOnName;
SPUser x = objGroup.Users[sUserLoginName];
if (x != null)
bUserIsInGroup = true;
}
}
}
});
}
catch
{
bUserIsInGroup = false;
}
return bUserIsInGroup;
}
/// isLoginUserInGroup
/// </summary>
/// <param name="group"></param>
/// <returns></returns>
public bool IsLogOnUserInGroup(string group)
{
var bUserIsInGroup = false;
try
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (var objSite = new SPSite(SPContext.Current.Site.Url))
{
using (var objWeb = objSite.OpenWeb())
{
SPGroup objGroup = SearchGroup(objWeb, group.Trim());
if (objGroup != null)
{
String sUserLoginName = LogOnName;
SPUser x = objGroup.Users[sUserLoginName];
if (x != null)
bUserIsInGroup = true;
}
}
}
});
}
catch
{
bUserIsInGroup = false;
}
return bUserIsInGroup;
}
No comments:
Post a Comment