i am trying to connect to remote windows 7 machine by using DirectoryEntry object. here is my code
DirectoryEntry obDirEntry = new DirectoryEntry("WinNT://hostName", "hostName\\testUser", "password123", AuthenticationTypes.Secure);
try
{
if (obDirEntry.Properties.Count > 0)
{
//ok
}
}
catch (Exception excp)
{}
if i am able to connect to remote windows server 2003 machine or local windows 7 machine , then i didn't get any error. But when i am trying to connect to remote windows 7 machine then i gets exception at line if (obDirEntry.Properties.Count > 0)
Exception :System.IO.FileNotFoundException: The network path was not found.
at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()
at System.DirectoryServices.DirectoryEntry.RefreshCache()
at System.DirectoryServices.DirectoryEntry.FillCache(String propertyName)
at System.DirectoryServices.PropertyCollection.get_Count()
I am able to ping that remote windows 7 m/c. firewall and UAC is also off. Problem is i am getting this problem on each remote windows 7 machine. I have tried to put ip adress in url instead of hostname, but in that case even on local machine i get above exception. nslookup command is able to resolve that remote m/c hostName. What may be reason for this ? What can be possible solution for this ? Thanks in advance !!