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); }
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; } }
public static bool IsInRole(this IPrincipal user, AppRoles role) { return user.IsInRole(role.ToString()); }
public static bool IsInRole(this IPrincipal user, AppRoles role) { return(user.IsInRole(role.ToString())); }