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); }
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); }
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); } }
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); }