Active directory configure on the different network and I want to access this active directory from another network ,how we can do this using c#.
Active directory is configured on the Network1 and we want to access this active directory from the ntework2
I have done the below code ant it is working fine with in the same network.
public bool IsUserAuthenticated(string domain, string userName)
{
try
{
DirectorySearcher dssearch = new DirectorySearcher(domain);
dssearch.Filter = string.Format("(&(objectClass=user)(sAMAccountName={0}))", userName);
//LDAP://CN=TestRahul Bhatnagar,CN=Users,DC=krishnas,DC=com
SearchResult sresult = dssearch.FindOne();
if (sresult == null)
{
return false;
}
}
catch (Exception ex)
{
return false;
}
return true;
}