public static bool IsAuthenticated1(string _domain, string username, string pwd) { string _path = WebConfig.getValuebyKey("LDAP"); string domainAndUsername = _domain + "\\" + username; DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd); try { Object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + username + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (result == null) { return(false); } else { return(true); } //update the new path to the user in directory // _path = result.Path; // string _filterAttribute = System.Convert.ToString(result.Properties("cn")(0)); } catch (Exception ex) { // throw new Exception("Error authenticating user." + ex.Message); var exm = ex.Message; return(false); } }
public static Byte[] GetReportR2(string _reportName, MyADO.MyParameterRS[] _reportParameter) { Byte[] result; try { ReportingWebService.ReportExecutionService RS = new ReportingWebService.ReportExecutionService(); // CredentialCache cache = new CredentialCache(); string accessUser = WebConfig.ReportUser(); string accessRWSPW = WebConfig.ReportPW(); string accessDomain = WebConfig.DomainName(); string reportingServices = WebConfig.ReportServices(); string currentDB = DBConnection.CurrentDB; string report = WebConfig.ReportPathWS() + currentDB + "/" + _reportName; string format = WebConfig.ReportFormat(); RS.Url = reportingServices; RS.Credentials = new System.Net.NetworkCredential(accessUser, accessRWSPW, accessDomain); string historyID = null; string devInfo = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; string encoding = ""; string mimeType = ""; ReportingWebService.Warning[] warnings = new ReportingWebService.Warning[0]; string[] streamIDs = null; ReportingWebService.ServerInfoHeader sh = new ReportingWebService.ServerInfoHeader(); //'ServerInfoHeader RS.ServerInfoHeaderValue = sh; //'ServerInfoHeaderValue = sh // ReportingWebService.Warning warning = new ReportingWebService.Warning(); int pLeng = _reportParameter.Length; ReportingWebService.ParameterValue[] rptParameters = new ReportingWebService.ParameterValue[pLeng]; int i = 0; foreach (MyADO.MyParameterRS para in _reportParameter) { rptParameters[i] = new ReportingWebService.ParameterValue(); rptParameters[i].Name = para.pName; rptParameters[i].Value = para.pValue.ToString(); i += 1; } // ReDim rptParameters(cnt - 1) ReportingWebService.ExecutionInfo execInfo = new ReportingWebService.ExecutionInfo(); ReportingWebService.ExecutionHeader execHeader = new ReportingWebService.ExecutionHeader(); execInfo = RS.LoadReport(report, historyID); RS.SetExecutionParameters(rptParameters, "en-us"); string extension = ""; string SessionId = RS.ExecutionHeaderValue.ExecutionID; // Console.WriteLine("SessionID: {0}", RS.ExecutionHeaderValue.ExecutionID); result = RS.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); return(result); } catch (Exception ex) { string error = ex.Message; return(new Byte[0]); } }