Okay so basically all we are doing here is changing the ValidateUser function so that it makes an LDAP connection using the username and password passed from the LogOn view form.
If it succeeds, we have a vaild user and password combination.
Changed ValidateUser function.
// new for authentication
public bool ValidateUser(string userName, string password)
LdapConnection ldc = new LdapConnection(new LdapDirectoryIdentifier((string)null, false, false));
NetworkCredential nc = new NetworkCredential(userName, password, "domainname.com");
ldc.Credential = nc;
ldc.AuthType = AuthType.Negotiate;
ldc.Bind(nc); // user has authenticated at this point, as the credentials were used to login to the dc.
string myvar = ldc.SessionOptions.DomainName;
validation = true;
validation = false;