public static List <PRIVLIST> GetScopePrivileges(SysScope scope) { // get all user privs related to the scope/function List <PRIVLIST> privList = new List <PRIVLIST>(); if (SessionManager.UserContext.PrivList != null) { PRIVLIST priv = new PRIVLIST(); if ((priv = SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100).FirstOrDefault()) != null) // system admon or company admin has privs to any resource { PRIVLIST adminPriv = new PRIVLIST(); adminPriv.PRIV_GROUP = priv.PRIV_GROUP; adminPriv.PRIV = priv.PRIV; adminPriv.SCOPE = scope.ToString(); privList.Add(adminPriv); } else { privList = SessionManager.UserContext.PrivList.Where(p => p.SCOPE.ToLower() == scope.ToString()).ToList(); } } return(privList); }
public static SysPriv GetMaxScopePrivilege(SysScope scope) { SysPriv maxPriv = SysPriv.none; PRIVLIST adminPriv = null; if ((adminPriv = SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100 && p.SCOPE.ToLower() == SysScope.system.ToString()).FirstOrDefault()) != null) // system admim or company admin has privs to any resource { maxPriv = (SysPriv)adminPriv.PRIV; } else { foreach (PRIVLIST priv in SessionManager.UserContext.PrivList.Where(l => l.SCOPE.ToLower() == scope.ToString()).ToList()) { if (priv.PRIV < (int)maxPriv) { maxPriv = (SysPriv)priv.PRIV; } } } return(maxPriv); }
public static bool CheckUserPrivilege(SysPriv priv, SysScope scope) { bool hasPriv = false; if (SessionManager.UserContext.PrivList != null) { if (SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100 && p.SCOPE.ToLower() == SysScope.system.ToString()).FirstOrDefault() != null) // system admim or company admin has privs to any resource { hasPriv = true; } else { if (priv >= SysPriv.approve && priv <= SysPriv.release5) { if (SessionManager.UserContext.PrivList.Where(p => p.PRIV == (int)priv && p.SCOPE.ToLower() == scope.ToString()).FirstOrDefault() != null) // check for any approval level if base approval priv given { hasPriv = true; } } else { if (SessionManager.UserContext.PrivList.Where(p => p.PRIV == (int)priv && p.SCOPE.ToLower() == scope.ToString()).FirstOrDefault() != null) // check specific priv & scope combination { hasPriv = true; } else { // check if config or admin privs for this scope if (SessionManager.UserContext.PrivList.Where(p => p.SCOPE == scope.ToString() && p.PRIV <= (int)SysPriv.config).FirstOrDefault() != null) { hasPriv = true; } } } } } return(hasPriv); }
public static bool CheckUserPrivilege(SysPriv priv, SysScope scope) { bool hasPriv = false; if (SessionManager.UserContext.PrivList != null) { if (SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100 && p.SCOPE.ToLower() == SysScope.system.ToString()).FirstOrDefault() != null) // system admim or company admin has privs to any resource { hasPriv = true; } else { if (SessionManager.UserContext.PrivList.Where(p => p.PRIV == (int)priv && p.SCOPE.ToLower() == scope.ToString()).FirstOrDefault() != null) // check specific priv & scope combination { hasPriv = true; } } } return(hasPriv); }