Last post Sep 03, 2014 02:41 AM by KimberlyDeborah
Aug 18, 2014 12:44 AM|ajay.kalol|LINK
I have did below code to authenticate user with active directory credential.
string strDomain = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Domain"]);
PrincipalContext pc = new PrincipalContext(ContextType.Domain, strDomain);
bool b = pc.ValidateCredentials(txtUsername.Text, txtPassword.Text.Trim());
It is working for some users and not working for some users. If user Reset it password then in most cases it works but after some time it failed again.
Please suggest me what i did wrong or what i need to do for active directory login ?
Suggest if there is another way to achieve this..
Aug 18, 2014 04:34 AM|ZLeonC|LINK
It is a bit difficult to tell what the issue is without the error stack trace. Can you please post what error you are receiving?
You could also use DirectoryServices namespace to authenticate users using the following snippet:
using (DirectoryEntry en = new DirectoryEntry("LDAP://localhost:389/CN=TestPartition,DC=TestDomain", "user1", "password", AuthenticationTypes.None))
en.RefreshCache(); //Attempt to bind
//Success if no error is thrown
Aug 22, 2014 01:10 AM|ajay.kalol|LINK
I have not any error in my code and at runtime. it just returns false.
Aug 23, 2014 10:04 AM|smirnov|LINK
You might try another constructor with ContextOptions
pc.ValidateCredentials(txtUsername.Text, txtPassword.Text, ContextOptions.SimpleBind);
Try other options if SimpleBind does not work.
Also avoid using Trim() on password field. If user typed wrong password you should not "help" him to correct it.
Sep 03, 2014 02:41 AM|KimberlyDeborah|LINK
You can use an Active Directory authentication server to enable your users to authenticate to the XTM device with their current network credentials. You must configure Active Directory server for Active Directory authentication to work correctly.