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;

 testsvr.subdomain.domain.com


pointemanAsked:
Who is Participating?
 
JuanCarnigliaConnect With a Mentor Commented:
Ok.

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
http://download.softerra.com/files/ldapbrowser26.msi

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.

Greetings
0
 
JuanCarnigliaCommented:
Try,

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

or

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.


Greetings.
0
 
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...
0
 
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"
 
0
 
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?
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.