To log in the active director we have to check the user id and password availability.We can achieve it through the following name space
using System.DirectoryServices;
The following code block will reach our target.
public bool GetValidUserId(string UserIdP, string PasswordP, string DomainNameP, out bool IsValidUserP) { IsValidUserP = false; try { DirectoryEntry deDirEntry = new DirectoryEntry("LDAP://" + DomainNameP, UserIdP,PasswordP,AuthenticationTypes.Secure); if (deDirEntry.Name.IndexOf("exception") != -1) { IsValidUserP = false; } IsValidUserP = true; } catch (Exception ex) { IsValidUserP = false; } return IsValidUserP; }
This above code will useful for the projects which are using the active directory users
Thanks Nathan
|
No responses found. Be the first to respond and make money from revenue sharing program.
|