/// <summary> /// Initializes a new instance of the <see cref="TicketsController"/> class. /// </summary> public TicketsController(ITicketService ticketService, ClaimsUtilities claimsUtilities) { _ticketService = ticketService; _claimsUtilities = claimsUtilities; }
/// <summary> /// Initializes a new instance of the <see cref="PurchaseController"/> class. /// </summary> public PurchasesController(IPurchaseService purchaseService, ClaimsUtilities claimsUtilities) { _purchaseService = purchaseService; _claimsUtilities = claimsUtilities; }
/// <summary> /// ImportMFAUsers method implementation /// </summary> public virtual MFAUserList ImportMFAUsers(string domain, string username, string password, string ldappath, DateTime?created, DateTime?modified, string mailattribute, string phoneattribute, PreferredMethod meth, bool usessl, bool disableall = false) { if (!string.IsNullOrEmpty(ldappath)) { ldappath = ldappath.Replace("ldap://", ""); ldappath = ldappath.Replace("ldaps://", ""); ldappath = ldappath.Replace("LDAP://", ""); ldappath = ldappath.Replace("LDAPS://", ""); } MFAUserList registrations = new MFAUserList(); try { using (DirectoryEntry rootdir = ADDSUtils.GetDirectoryEntry(domain, username, password, ldappath, usessl)) { string qryldap = string.Empty; qryldap = "(&"; qryldap += "(objectCategory=user)(objectClass=user)" + ClaimsUtilities.BuildADDSUserFilter("*"); if (created.HasValue) { qryldap += "(whenCreated>=" + created.Value.ToString("yyyyMMddHHmmss.0Z") + ")"; } if (modified.HasValue) { qryldap += "(whenChanged>=" + modified.Value.ToString("yyyyMMddHHmmss.0Z") + ")"; } qryldap += ")"; using (DirectorySearcher dsusr = new DirectorySearcher(rootdir, qryldap)) { dsusr.PropertiesToLoad.Clear(); dsusr.PropertiesToLoad.Add("objectGUID"); dsusr.PropertiesToLoad.Add("userPrincipalName"); dsusr.PropertiesToLoad.Add("sAMAccountName"); dsusr.PropertiesToLoad.Add("msDS-PrincipalName"); dsusr.PropertiesToLoad.Add("userAccountControl"); if (!string.IsNullOrEmpty(mailattribute)) { dsusr.PropertiesToLoad.Add(mailattribute); } else { dsusr.PropertiesToLoad.Add("mail"); dsusr.PropertiesToLoad.Add("otherMailbox"); } if (!string.IsNullOrEmpty(phoneattribute)) { dsusr.PropertiesToLoad.Add(phoneattribute); } else { dsusr.PropertiesToLoad.Add("mobile"); dsusr.PropertiesToLoad.Add("otherMobile"); dsusr.PropertiesToLoad.Add("telephoneNumber"); } dsusr.SizeLimit = 0; // _host.MaxRows; SearchResultCollection src = dsusr.FindAll(); if (src != null) { foreach (SearchResult sr in src) { MFAUser reg = new MFAUser(); using (DirectoryEntry DirEntry = ADDSUtils.GetDirectoryEntry(domain, username, password, sr, usessl)) { if (DirEntry.Properties["objectGUID"].Value != null) { reg.ID = new Guid((byte[])DirEntry.Properties["objectGUID"].Value).ToString(); if (sr.Properties[ClaimsUtilities.GetADDSUserAttribute()][0] != null) { reg.UPN = sr.Properties[ClaimsUtilities.GetADDSUserAttribute()][0].ToString(); if (!string.IsNullOrEmpty(mailattribute)) { if (DirEntry.Properties[mailattribute].Value != null) { reg.MailAddress = DirEntry.Properties[mailattribute].Value.ToString(); } } else { if (DirEntry.Properties["otherMailbox"].Value != null) { reg.MailAddress = DirEntry.Properties["otherMailbox"].Value.ToString(); } else if (DirEntry.Properties["mail"].Value != null) { reg.MailAddress = DirEntry.Properties["mail"].Value.ToString(); } } if (!string.IsNullOrEmpty(phoneattribute)) { if (DirEntry.Properties[phoneattribute].Value != null) { reg.PhoneNumber = DirEntry.Properties[phoneattribute].Value.ToString(); } } else { if (DirEntry.Properties["mobile"].Value != null) { reg.PhoneNumber = DirEntry.Properties["mobile"].Value.ToString(); } else if (DirEntry.Properties["otherMobile"].Value != null) { reg.PhoneNumber = DirEntry.Properties["otherMobile"].Value.ToString(); } else if (DirEntry.Properties["telephoneNumber"].Value != null) { reg.PhoneNumber = DirEntry.Properties["telephoneNumber"].Value.ToString(); } } reg.PreferredMethod = meth; reg.OverrideMethod = string.Empty; if (disableall) { reg.Enabled = false; } else if (DirEntry.Properties["userAccountControl"] != null) { int v = Convert.ToInt32(DirEntry.Properties["userAccountControl"].Value); reg.Enabled = ((v & 2) == 0); } else { reg.Enabled = true; } registrations.Add(reg); } } }; } } } } } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5100); throw new Exception(ex.Message); } return(registrations); }
/// <summary> /// Initializes a new instance of the <see cref="AccountController"/> class. /// </summary> public AccountController(IAccountService accountService, ClaimsUtilities claimsUtilities) { _accountService = accountService; _claimsUtilities = claimsUtilities; }