Monday, March 9, 2009

How to check the authorization to load a page ?

I achived to check the authrization of user follwoing way.

public static bool IsUserExistsInGroup(string aGroupName, SPWeb aWeb, string aUserName)
{
SPGroup userGroup;
SPUser user;
bool userExists = false;
try
{
userGroup = aWeb.Site.RootWeb.SiteGroups[aGroupName];
try
{
user = userGroup.Users[aUserName];

if (user != null)
{
userExists = true;
}
}
catch
{

}
}
catch (Exception ex)
{
throw ex;
}
return userExists;
}

No comments: