DirectoryEntry LDAP From Network Computer Fails?

Posted on 2008-11-18
Last Modified: 2012-05-05

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;

Question by:pointeman
    LVL 7

    Expert Comment


    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.


    Author Comment

    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...

    Author Comment

    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"
    LVL 7

    Accepted Solution


    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.


    Author Comment

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now