The below code will help you to check wether a specified user exists on the domain controlller or not.
bool AdsVlaid = false;
string username = "it";
string domain="server";
string path = String.Format("WinNT://{0}/{1},user", domain, username);
try
{
DirectoryEntry.Exists(path);
AdsVlaid= true;
}
catch (Exception ex)
{
AdsVlaid = false;
MessageBox.Show(ex.Message);
// For WinNT provider DirectoryEntry.Exists throws an exception
// instead of returning false so we need to trap it.
}
For more infomation please visit the below links
http://www.codeproject.com/KB/system/everythingInAD.aspx
http://stackoverflow.com/questions/1329833/how-to-check-if-windows-user-account-name-exists-in-domain
bool AdsVlaid = false;
string username = "it";
string domain="server";
string path = String.Format("WinNT://{0}/{1},user", domain, username);
try
{
DirectoryEntry.Exists(path);
AdsVlaid= true;
}
catch (Exception ex)
{
AdsVlaid = false;
MessageBox.Show(ex.Message);
// For WinNT provider DirectoryEntry.Exists throws an exception
// instead of returning false so we need to trap it.
}
For more infomation please visit the below links
http://www.codeproject.com/KB/system/everythingInAD.aspx
http://stackoverflow.com/questions/1329833/how-to-check-if-windows-user-account-name-exists-in-domain