Example #1
0
 public bool IsAuthenticated(String usr, String password)
 {
     try
     {
         var aDirV = new ActiveDirectoryValidator(_path_LDAP);
         return(aDirV.IsAuthenticated(_domainName, usr, password));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #2
0
 public bool IsAuthenticated(String usr, String password)
 {
     try
     {
         var aDirV = new ActiveDirectoryValidator(_path_LDAP);
         return aDirV.IsAuthenticated(_domainName, usr, password);
     }
     catch (Exception)
     {
         return false;
     }
 }
Example #3
0
    private void AutenticateUser(string domainName, string userName, string password)
    {
        // Path to you LDAP directory server.
        // Contact your network administrator to obtain a valid path.


        string adPath = "LDAP://corp.nutanix.com";
        ActiveDirectoryValidator adAuth = new ActiveDirectoryValidator(adPath);

        if (true == adAuth.IsAuthenticated(domainName, userName, password))
        {
            // Create the authetication ticket
            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(60), false, "");
            // Now encrypt the ticket.
            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
            // Create a cookie and add the encrypted ticket to the
            // cookie as data.
            HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            // Add the cookie to the outgoing cookies collection.
            HttpContext.Current.Response.Cookies.Add(authCookie);
            // Redirect the user to the originally requested page
            HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(userName, false));
        }
    }