/// <summary> /// This is a simple method that tries to fetch 1 record of the specified report /// and if 0 or 1 record return then the authN & authZ to this report is validated /// otherwise throws an exception /// </summary> /// <returns></returns> public bool ValidateAccessToReport() { try { ReportVisitor visitor = new DefaultReportVisitor(); int res = RetrieveData(visitor, new QueryFilter() { TopCount = 1 }); if (res == 0 || res == 1) { return(true); } else { throw new ApplicationException("Tried to validate your credentials against the report specified, however the response we received from the server did not match what we expected to receive. Please try again."); } } catch (Exception ex) { if (ex is AggregateException) { if (ex.InnerException is HttpRequestException) { //Indicates that this is an HTTP request unauthorized exception if (ex.InnerException.Message.Contains("401")) { return(false); } else { throw ex; } } else { throw ex; } } else { throw ex; } } }
/// <summary> /// This RetrieveData method the built-in ReportVisitor (Console) /// </summary> public void RetrieveData() { ReportVisitor visitor = new DefaultReportVisitor(); RetrieveData(visitor); }