Ejemplo n.º 1
0
        public bool existsUser(string userId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.CheckUserExistsSQL);

            dba.addInParameter(cmd, "@user_id", DbType.String, userId);
            object o = dba.executeScalar(cmd);

            return(o != null);
        }
Ejemplo n.º 2
0
        public void appendUserRole(string userId, string roleId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.CheckUserRolesSQl);

            dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
            dba.addInParameter(cmd, "@userId", DbType.String, userId);
            object c = dba.executeScalar(cmd);

            if ((int)c < 1)
            {
                cmd = dba.getSqlStringCommand(SecurityDataScripts.AppendUserRolesSQl);
                dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                dba.addInParameter(cmd, "@userId", DbType.String, userId);
            }
            dba.execNonQuery(cmd);
        }
Ejemplo n.º 3
0
        public static PermissionTypes getRoleObjectPermission(string roleId, string objectId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.RoleObjectPermissionSql);

            dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
            dba.addInParameter(cmd, "@objectId", DbType.String, objectId);
            object ret = dba.executeScalar(cmd);

            if (ret != null && ret is int)
            {
                return((PermissionTypes)ret);
            }
            else
            {
                return(PermissionTypes.None);
            }
        }
Ejemplo n.º 4
0
        public bool appendRoles(UserRoleIds userRoleIds)
        {
            string        userId = userRoleIds.UserId;
            DatabaseAdmin dba    = SecuritySettings.getDBA();

            for (int i = 0; i < userRoleIds.RoleIds.Count; i++)
            {
                DbCommand cmd    = dba.getSqlStringCommand(SecurityDataScripts.CheckUserRolesSQl);
                string    roleId = userRoleIds.RoleIds[i];
                dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                dba.addInParameter(cmd, "@userId", DbType.String, userId);
                object c = dba.executeScalar(cmd);
                if ((int)c < 1)
                {
                    cmd = dba.getSqlStringCommand(SecurityDataScripts.AppendUserRolesSQl);
                    dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                    dba.addInParameter(cmd, "@userId", DbType.String, userId);
                }
                dba.execNonQuery(cmd);
            }
            return(true);
        }