private StaffADProfile GetStaffInformation(string username, string password, string domain) { SearchResult rs = null; try { Debug.WriteLine(username); Debug.WriteLine(password); Debug.WriteLine(domain); rs = SearchUserByUserName(GetDirectorySearcher(username, password, domain)); if (rs != null) { DirectoryEntry de = rs.GetDirectoryEntry(); staffADProfile.employee_number = String.IsNullOrEmpty(de.Properties["description"].Value.ToString()) ? String.Empty : de.Properties["description"].Value.ToString(); //staffADProfile.branch_name = String.IsNullOrEmpty(de.Properties["telephoneNumber"].Value.ToString()) ? String.Empty : de.Properties["telephoneNumber"].Value.ToString(); //staffADProfile.branch_address = String.IsNullOrEmpty(de.Properties["streetAddress"].Value.ToString()) ? String.Empty : de.Properties["streetAddress"].Value.ToString(); //staffADProfile.mobile_phone = String.IsNullOrEmpty(de.Properties["mobile"].Value.ToString()) ? String.Empty : de.Properties["mobile"].Value.ToString(); //staffADProfile.gsm = String.IsNullOrEmpty(de.Properties["telephoneNumber"].Value.ToString()) ? String.Empty : de.Properties["telephoneNumber"].Value.ToString(); //staffADProfile.jobtitle = String.IsNullOrEmpty(de.Properties["title"].Value.ToString()) ? String.Empty : de.Properties["title"].Value.ToString(); //staffADProfile.office_ext = String.IsNullOrEmpty(de.Properties["pager"].Value.ToString()) ? String.Empty : de.Properties["pager"].Value.ToString(); //staffADProfile.department = String.IsNullOrEmpty(de.Properties["department"].Value.ToString()) ? String.Empty : de.Properties["department"].Value.ToString(); staffADProfile.user_logon_name = String.IsNullOrEmpty(de.Properties["sAMAccountName"].Value.ToString()) ? String.Empty : de.Properties["sAMAccountName"].Value.ToString(); staffADProfile.email = String.IsNullOrEmpty(de.Properties["mail"].Value.ToString()) ? String.Empty : de.Properties["mail"].Value.ToString(); staffADProfile.membership = getMemberships(de); logWriter.WriteErrorLog(string.Format("GetStaffInformation : User found!!! / {0}", staffADProfile.user_logon_name)); } else { staffADProfile = null; logWriter.WriteErrorLog(string.Format("GetStaffInformation : User not found!!! / {0}", staffADProfile.user_logon_name)); } } catch (Exception ex) { logWriter.WriteErrorLog(string.Format("GetStaffInformation : Exception!!! / {0}", ex.Message)); staffADProfile = null; } finally { Dispose(); rs = null; } return(staffADProfile); }
public StaffADProfile GetStaffProfile() { logWriter.WriteErrorLog(string.Format("Entered GetStaffProfile")); try { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/"); System.Configuration.KeyValueConfigurationElement sADUser = null; System.Configuration.KeyValueConfigurationElement sADPassword = null; System.Configuration.KeyValueConfigurationElement sDomain = null; if (rootWebConfig.AppSettings.Settings.Count > 0) { sADUser = rootWebConfig.AppSettings.Settings["sADUser"]; sADPassword = rootWebConfig.AppSettings.Settings["sADPassword"]; sDomain = rootWebConfig.AppSettings.Settings["sDomain"]; if (sADUser == null) { staffADProfile = null; logWriter.WriteErrorLog(string.Format("No ad admin profile application string")); } else { staffADProfile = GetStaffInformation(sADUser.Value.ToString(), sADPassword.Value.ToString(), sDomain.Value.ToString()); } } else { staffADProfile = null; } } catch (Exception ex) { staffADProfile = null; logWriter.WriteErrorLog(string.Format(" GetStaffProfile : Exception / {0} / {1}", staffADProfile.employee_number, ex.Message)); } return(staffADProfile); }
public ActiveDirectoryQuery(StaffADProfile staffADProfile) { this.staffADProfile = staffADProfile; this.logWriter = new LogWriter(); }
public List<InputClass> GetMyIncidentEntry(StaffADProfile staffADProfile) { List<InputClass> RequestList = new List<InputClass>(); try { BVNDataContext projectconn = new BVNDataContext(); var Projectinfo = (from distinct in projectconn.Tb_BvnIncidents where (distinct.StaffNumber == staffADProfile.employee_number) select new { RequestID = distinct.DocumentID, InitiatorName = distinct.StaffName, AccountName = distinct.AccountName, AccountNumber = distinct.AccountNumber, InitiatorBranch = distinct.StaffBranch, RequestStage = distinct.InputStage, date_Submitted = distinct.DateSubmitted , accountNameArray = distinct.AccountNameArray, accountNumberArray = distinct.AccountNumberArray, accountStatusArrary = distinct.AccountStatusArray, BVN = distinct.BVN }); foreach (var requestList in Projectinfo) { InputClass Myrequest = new InputClass(); Profile profile = new Profile(); Account account = new Account(); profile.StaffName = requestList.InitiatorName; profile.Branch = requestList.InitiatorBranch; account.AccountName = requestList.AccountName; account.AccountNumber = requestList.AccountNumber; account.AccountName = (requestList.accountNameArray == null) ? "" : requestList.accountNameArray.Replace(";", "<BR><hr><BR>"); account.AccountNumber = (requestList.accountNumberArray == null) ? "" : requestList.accountNumberArray.Replace(";", "<BR><hr><BR>"); account.AccountStatus = (requestList.accountStatusArrary == null) ? "" : requestList.accountStatusArrary.Replace(";", "<BR><hr><BR>"); account.BVN = requestList.BVN; Myrequest.RequesterDetails = profile; Myrequest.AccountDetials= account; Myrequest.InputStage = "IC & A Review"; Myrequest.DateSubmitted = requestList.date_Submitted; Myrequest.DocumentID = requestList.RequestID; RequestList.Add(Myrequest); } } catch (Exception ex) { // return ex.Message; } return RequestList; }