設置我的枚舉這樣的..
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");
}
,你可以設置一個枚舉並在頁面加載根據用戶屬於哪個組或ACCESSLEVEL你可以設置的可見性,我已經做了這個MenuItems多次之前在過去..我會建議這樣做與MenuItems本人 – MethodMan
謝謝,我會嘗試研究枚舉.. – willie
我會張貼一個我正在談論的例子about和on Page_Load事件是代碼去MasterPage.cs的地方 – MethodMan