列挙型をこのように設定します。
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を使用して、SQLServerまたはユーザー権限をチェックする他の手段を使用できるユーザーアクセス権を決定します
これはコードの例にすぎません。コード全体を貼り付けるつもりはありませんが、アイデアを得る必要があります。
_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");
}