public override bool Equals(object obj)
        {
            PreferredMethod paramobj = PreferredMethod.Choose;

            if (obj is PreferredMethod)
            {
                paramobj = (PreferredMethod)obj;
            }
            else if (obj is MMCProviderItem)
            {
                paramobj = ((MMCProviderItem)obj).ID;
            }
            else
            {
                return(false);
            }
            if (paramobj == this.ID)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// Clear method implementation
 /// </summary>
 public void Clear()
 {
     filterfield    = DataFilterField.UserName;
     filteroperator = DataFilterOperator.Contains;
     filtermethod   = PreferredMethod.None;
     filtervalue    = string.Empty;
     enabledonly    = false;
     filterisactive = false;
 }
        public ActionResult Create(PreferredMethod preferredmethod)
        {
            if (ModelState.IsValid)
            {
                db.PreferredMethods.Add(preferredmethod);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.whID = new SelectList(db.Warehouses, "whID", "whName", preferredmethod.whID);
            return View(preferredmethod);
        }
 public override bool Equals(object obj)
 {
     PreferredMethod paramobj = PreferredMethod.Choose;
     if (obj is PreferredMethod)
         paramobj = (PreferredMethod)obj;
     else if (obj is MMCProviderItem)
         paramobj = ((MMCProviderItem)obj).ID;
     else
         return false;
     if (paramobj == this.ID)
         return true;
     else
         return false;
 }
 /// <summary>
 /// IsProviderAvailableForUser method implementation
 /// </summary>
 public static bool IsProviderAvailableForUser(AuthenticationContext ctx, PreferredMethod method)
 {
     return(RuntimeAuthProvider.IsProviderAvailableForUser(ctx, method));
 }
 /// <summary>
 /// GetProviderInstance method implementation
 /// </summary>
 public static IExternalProvider GetProviderInstance(PreferredMethod method)
 {
     return(RuntimeAuthProvider.GetProviderInstance(method));
 }
Example #7
0
        /// <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);
        }
 public ActionResult Edit(PreferredMethod preferredmethod)
 {
     if (ModelState.IsValid)
     {
         db.Entry(preferredmethod).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.whID = new SelectList(db.Warehouses, "whID", "whName", preferredmethod.whID);
     return View(preferredmethod);
 }
Example #9
0
 public abstract RegistrationList GetImportUserRegistrations(string domain, string username, string password, string ldappath, DateTime?created, DateTime?modified, string mailattribute, string phoneattribute, PreferredMethod method, bool disableall = false);
Example #10
0
 /// <summary>
 /// GetImportUserRegistrations
 /// </summary>
 public override RegistrationList GetImportUserRegistrations(string domain, string username, string password, string ldappath, DateTime?created, DateTime?modified, string mailattribute, string phoneattribute, PreferredMethod method, bool disableall = false)
 {
     throw new NotImplementedException("Not supported by SQL Provider");
 }