Ejemplo n.º 1
0
        public override bool ValidateUser(string username, string password)
        {
            string      path       = ConfigurationManager.AppSettings["LDAPPath"];
            string      myUsername = username;
            string      uid        = ConfigurationManager.AppSettings["LDAPUID"];
            string      user       = string.Format(uid, myUsername.ToLower());
            EEAServices myService  = new EEAServices();
            string      serviceUrl = ConfigurationManager.AppSettings["LDAPServiceAddress"];

            myService.Url = serviceUrl;

            var settings = System.Web.Configuration.WebConfigurationManager.AppSettings;

            var GetRoles = from string r in settings.Keys
                           where r.StartsWith("Role")
                           select settings[r];

            object mylogin = new object();

            try
            {
                foreach (var r in GetRoles)
                {
                    mylogin = myService.LDAPAuthenticationCheck(user, password, path, r);

                    bool pass = (mylogin.ToString().Contains("1")); //"0 - Rejected: User found but role not found"
                    if (pass)
                    {
                        return(true);
                    }
                }
            }
            catch (System.Net.WebException we)
            {
                LogEntry log = new LogEntry();

                log.EventId  = 300;
                log.Message  = "Failure in EEAMembershipProvider. User = "******". " + we.Message;
                log.Severity = System.Diagnostics.TraceEventType.Error;
                log.Categories.Add("Login");
                log.Priority = 5;
                Logger.Write(log);
            }
            catch (Exception ex)
            {
                LogEntry log = new LogEntry();

                log.EventId  = 300;
                log.Message  = "Failure in EEAMembershipProvider " + ex.Message;
                log.Severity = System.Diagnostics.TraceEventType.Warning;
                log.Categories.Add("Login");
                log.Priority = 5;
                Logger.Write(log);

                throw;
            }


            return(false);
        }
Ejemplo n.º 2
0
        public override bool ValidateUser(string username, string password)
        {
            bool        valid      = false;
            string      path       = "LDAP://ldap.eionet.europa.eu:389";
            string      myUsername = username;
            string      user       = string.Format("uid={0},ou=Users,o=Eionet,l=Europe", myUsername);
            EEAServices myService  = new EEAServices();

            myService.Url = "http://dataconnector.eea.europa.eu/SoapServices/Services.asmx";

            string role = "/l=Europe/o=Eionet/ou=Roles/cn=extranet/cn=extranet-eprtr/cn=extranet-eprtr-eprtrcms";

            object mylogin = new object();

            mylogin = myService.LDAPAuthenticationCheck(user, password, path, role);

            bool pass = (mylogin.ToString().Contains("1"));

            return(pass);
        }