Exemplo n.º 1
0
        public static RoleGrant loadCurrentUserDirectRoleGrant(OracleDataReader odr)
        {
            string username;
            string grantedRole;
            bool   adminOption;
            bool   defaultRole;
            bool   directGrant;

            if (odr.IsDBNull(odr.GetOrdinal("username")) ||
                odr.IsDBNull(odr.GetOrdinal("granted_role")))
            {
                return(null);
            }

            username = odr.GetString(odr.GetOrdinal("username"));
            if (username.Equals("PUBLIC"))
            {
                directGrant = false;
            }
            else
            {
                directGrant = true;
            }

            grantedRole = odr.GetString(odr.GetOrdinal("granted_role"));

            adminOption = RoleGrant.ParseAdminOption(odr.GetValue(odr.GetOrdinal("admin_option")));
            defaultRole = RoleGrant.ParseDefaultRole(odr.GetValue(odr.GetOrdinal("default_role")));

            return(new RoleGrant(username, grantedRole, adminOption, defaultRole, directGrant));
        }
Exemplo n.º 2
0
 private void addInheritedGrants(ReadOnlyCollection <RoleGrant> grants)
 {
     foreach (RoleGrant grant in grants)
     {
         // create an inherited grant
         RoleGrant iGrant =
             new RoleGrant(grant, userRole.Name, false);
         // add it
         roleGrants.Add(iGrant);
     }
 }
Exemplo n.º 3
0
        public RoleGrant(RoleGrant grant, string grantee, bool adminOption)
        {
            if(grant == null)
                throw new ArgumentNullException("Grant");

            this.grantee = grantee;
            this.grantedRole = grant.GrantedRole;
            this.adminOption = adminOption;
            this.weakReference = false;
            this.roleReference = grant.Role;
            this.directGrant = false;
            this.defaultRole = false;
        }
Exemplo n.º 4
0
        public RoleGrant(RoleGrant grant, string grantee, bool adminOption)
        {
            if (grant == null)
            {
                throw new ArgumentNullException("Grant");
            }

            this.grantee       = grantee;
            this.grantedRole   = grant.GrantedRole;
            this.adminOption   = adminOption;
            this.weakReference = false;
            this.roleReference = grant.Role;
            this.directGrant   = false;
            this.defaultRole   = false;
        }
Exemplo n.º 5
0
        public static RoleGrant loadDbaRoleGrant(OracleDataReader odr)
        {
            string grantee;
            string grantedRole;
            bool   adminOption;
            bool   defaultRole;

            if (odr.IsDBNull(odr.GetOrdinal("grantee")) ||
                odr.IsDBNull(odr.GetOrdinal("granted_role")))
            {
                return(null);
            }

            grantee     = odr.GetString(odr.GetOrdinal("grantee"));
            grantedRole = odr.GetString(odr.GetOrdinal("grantedRole"));
            adminOption = RoleGrant.ParseAdminOption(odr.GetValue(odr.GetOrdinal("admin_option")));
            defaultRole = RoleGrant.ParseDefaultRole(odr.GetValue(odr.GetOrdinal("default_role")));

            return(new RoleGrant(grantee, grantedRole, adminOption, defaultRole, true));
        }
Exemplo n.º 6
0
        public static RoleGrant loadCurrentUserAccessibleRoleGrant(OracleDataReader odr)
        {
            string role;
            string grantedRole;
            bool   adminOption;
            bool   directGrant = true;

            if (odr.IsDBNull(odr.GetOrdinal("role")) ||
                odr.IsDBNull(odr.GetOrdinal("granted_role")))
            {
                return(null);
            }

            role        = odr.GetString(odr.GetOrdinal("role"));
            grantedRole = odr.GetString(odr.GetOrdinal("grantedRole"));

            adminOption = RoleGrant.ParseAdminOption(odr.GetValue(odr.GetOrdinal("admin_option")));

            return(new RoleGrant(role, grantedRole, adminOption, false, directGrant));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Loads role grants from ROLE_ROLE_PRIVS (current user accessible roles)
        /// </summary>
        bool loadCurrentUserRoleGrants()
        {
            OracleCommand    cmd = new OracleCommand(CURRENT_USER_ROLE_ROLE_GRANTS_SELECT, conn);
            OracleDataReader odr = cmd.ExecuteReader();

            if (!odr.HasRows)
            {
                return(false);
            }

            rolesGrants.Clear();

            while (odr.Read())
            {
                RoleGrant grant = loadCurrentUserAccessibleRoleGrant(odr);
                rolesGrants.Add(grant);
            }

            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Loads role grants from DBA_ROLE_PRIVS
        /// </summary>
        bool loadAllRoleGrants()
        {
            OracleCommand    cmd = new OracleCommand(DBA_ROLE_PRIVS_SELECT, conn);
            OracleDataReader odr = cmd.ExecuteReader();

            if (!odr.HasRows)
            {
                return(false);
            }

            rolesGrants.Clear();

            while (odr.Read())
            {
                RoleGrant grant = loadDbaRoleGrant(odr);
                rolesGrants.Add(grant);
            }

            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Loads role grants from USER_ROLE_PRIVS (roles directly granted to current user)
        /// </summary>
        bool loadCurrentUserDirectRoleGrants()
        {
            OracleCommand    cmd = new OracleCommand(CURRENT_USER_DIRECT_ROLE_GRANTS_SELECT, conn);
            OracleDataReader odr = cmd.ExecuteReader();

            if (!odr.HasRows)
            {
                return(false);
            }

            // flush current user direct role grants
            rolesGrants.Clear();

            while (odr.Read())
            {
                RoleGrant grant = loadCurrentUserDirectRoleGrant(odr);
                rolesGrants.Add(grant);
            }

            return(true);
        }
Exemplo n.º 10
0
 private void addInheritedGrants(ReadOnlyCollection<RoleGrant> grants)
 {
     foreach (RoleGrant grant in grants)
     {
         // create an inherited grant
         RoleGrant iGrant =
             new RoleGrant(grant, userRole.Name, false);
         // add it
         roleGrants.Add(iGrant);
     }
 }