private DirectoryEntry entry;
entry = new DirectoryEntry("LDAP://" + oDomainName + "", oUserName,
oPassword, System.DirectoryServices.AuthenticationTypes.Secure);
private DirectorySearcher ds;
entry = new DirectoryEntry("LDAP://" + oDomainName + "", oUserName,
oPassword, System.DirectoryServices.AuthenticationTypes.Secure);
Then made a search in active directory against your login credentials, if searchresult returns object of the user it means that user exist in the Active Directory with the submitted credentials.
The source code also contains a method "GetDomains" which returns an ArrayList having all the domains that are present in the network
.
public ArrayList GetDomains()
{
ArrayList arrDomains = new ArrayList();
DirectoryEntry ParentEntry = new DirectoryEntry();
try
{
ParentEntry.Path = "WinNT:";
foreach (DirectoryEntry childEntry in ParentEntry.Children)
{
switch (childEntry.SchemaClassName)
{
case "Domain":
{
arrDomains.Add(childEntry.Name);
break;
}
default:
{
break;
}
}} }
catch (Exception e)
{
}
finally
{
ParentEntry = null;
}
return arrDomains;
}
Try this and let me know if this thing work aur not