我像这样设置我的枚举..
public enum AccessRights
{
LogisticsCoordinator_RW, //Read-Write,
LogisticsCoordinator_R, //Read only Purchasing and Inventory
ProcurementManager_RW, // Read-Write access to track purchase of Sand on monitor on hand Inventory
ProcurementManager_R, //read access to Create Frac Jobs , Dispatch and reroute
SystemAdministrator, //Full Rights to Vertex_Personnel only
StudentManagement_R, //Read Access Only
AppAdministrator_R,
NonAdmin,
None,
Full,
Default
}
现在我使用 LDAP/ActiveDirectory 来确定用户访问权限,您可以使用 SQL Server 或其他一些检查用户权限的方法
这只是代码的一个示例,我不会粘贴整个代码,但您应该明白
_ADPath = ConfigurationManager.AppSettings["ADPath"];
_Domain = ConfigurationManager.AppSettings["ISDDomain"];
_UserId = ((BasePage)Page).CurrentUser;
string[] strUser = _UserId.Split('\\');
if (strUser.Length == 2)
{
_UserId = strUser[1];
}
// uxLBLoginError.Text = "";
try
{
LdapAuthentication la = new LdapAuthentication(_ADPath);
if (!AdPassRequired)
{
//use this if password not required
_authenticated = la.IsUserGroupMember(_UserId, AdGroupToPass);
}
//else
//{
// // use this if password is required
// _authenticated = la.IsAuthenticated(_Domain, _UserId, strPassword);
//}
if (_authenticated)
{
//test the roles functionality
((BasePage)Page).GetDBRoleNames(_UserId);
Session["User_Initial_Validated"] = true;
Session["isDefault_Loaded"] = true;
Session["AccessRights"] = AccessRights.Default;
Session["UserId"] = _UserId;
//Response.Redirect("~/Default.aspx");
}