DirectoryEntry LDAP From Network Computer Fails?

The following DirectoryEnty code works only on the actual Domain Controller.

DirectoryEntry de = new DirectoryEntry("LDAP://" + dcName, adminUser, adminPass);

I receive the following error while running this code on a networked computer.

"The specified domain either does not exist or could not be contacted"

I've tried several different dcName strings from the following DC Name with Full Domain;

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


DirectoryEntry de = new DirectoryEntry("GC://RootDSE/" + dcName, adminUser, adminPass);


DirectoryEntry de = new DirectoryEntry("GC://RootDSE/" + dcName, adminUser, adminPass, AuthenticationTypes.Secure);

Is your networked computer "attached" to the domain (Do you log on to it with a user of that domain, or a local user?).

if you are not logged onto the domain, you have to specify the domain name when binding to an AD object.

pointemanAuthor Commented:
I have 1 - Windows 2000 DC and 1 - XP Pro laptop using domain login to the DC.
I have also giving the laptop user admin rights on both local and DC to eliminate user right's problems.
I'll try you advice and let you know, thanks...
pointemanAuthor Commented:
Well niether examples worked.
Also thought I would try this with a different button_click:

Domain thisDomain = Domain.GetCurrentDomain();
lblDomain.Text = thisDomain.ToString();
 I then received this error:
"Current security context is not associated with an Active Directory domain or Forest"

If you are logged on the domain the simple:

DirectoryEntry de = new DirectoryEntry("GC://RootDSE/" + dcName);

... should work. If it doesn't it is a security issue.

You should download and check this app out : LdapBrowser

It's a free app to surf the AD, using custom user and password. That way you can test a user's permissions on a specific object.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pointemanAuthor Commented:
Really all I need to accomplish is return a list of all computers Names & IP's on the same subnet. I would like to find a simple solution other that the AD classes if possible. Looks like the DirectoryEntry for AD has too many variables. Some examples show ("LDAP://" + dcName) or (LDAP://RootDSE/ + dcName), etc... While non-AD networks use (WINNT://)...
Q. Do you know of a simple soluton that will find all computers & IP's in any Micosoft network?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.