コード例 #1
0
ファイル: Authorize.cs プロジェクト: tntice/ERMA
        public static bool IsAuthorized(AppRoles role, String UserName)
        {
            bool returnValue = true;

            try
            {
                //string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString().ToUserIDWithoutDomain().ToUpper();
                string user = UserName;


                if (TACAuthorization.HasPersmission("ERMA", user, role.ToString(), false))
                {
                    returnValue = true;
                }
                else
                {
                    returnValue = false;
                }
            }
            catch
            {
                returnValue = false;
            }
            return(returnValue);
        }
コード例 #2
0
        public void SetAppRole(AppRoles role, string pass)
        {
            var conn         = AviaSalesConnection.Database.Connection;
            var initialState = conn.State;

            try
            {
                if (initialState != ConnectionState.Open)
                {
                    conn.Open();
                }
                using (DbCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "sp_setapprole";
                    cmd.Parameters.Add(new SqlParameter("@rolename", role.ToString()));
                    cmd.Parameters.Add(new SqlParameter("@password", pass));
                    cmd.CommandType = CommandType.StoredProcedure;
                    var su = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                logger.ConditionalDebug(ex.Message);
                throw;
            }
        }
コード例 #3
0
 public static bool IsInRole(this IPrincipal user, AppRoles role)
 {
     return user.IsInRole(role.ToString());
 }
コード例 #4
0
 public static bool IsInRole(this IPrincipal user, AppRoles role)
 {
     return(user.IsInRole(role.ToString()));
 }