Solved

working with System.DirectoryServices

Posted on 2004-10-25
1,022 Views
Last Modified: 2008-01-09
I have a page where I am calling the directory service name space using the following

<%@ import Namespace="System.DirectoryServices" %>

then I have this in my page

 Dim objDE As New DirectoryServices.DirectoryEntry(CStr(Application("LDAP://CN=Users,DC=mydomain,DC=com")))

I am getting the following error.

Compiler Error Message: BC30002: Type 'DirectoryServices.DirectoryEntry' is not defined.

How can I get around this?
0
Question by:NickMalloy
    8 Comments
     
    LVL 8

    Expert Comment

    by:daffodils
    You also need to add a reference to the assembly to your project - just specifying it in the using clause isn't good enough.

    Basically.. You need to add "DirectoryServices.dll" as a reference... it needs the assembly reference to be added to the project.. IN ADDITION to the "<%@ import Namespace="" %> clause".
    What adding a reference means is that when the application compiles, it KNOWS that it has to include the "DirectoryServices.dll" in the list of files to be compiled.

    Go to your project tree, pick your project, and the "References" node below the project node.
    Right-click to add a reference, and find the System.DirectoryServices assembly, add it.

    0
     
    LVL 8

    Expert Comment

    by:daffodils
    0
     

    Author Comment

    by:NickMalloy
    I am not using Visual studio for this project. I am simply using Dreamweaver MX
    0
     
    LVL 8

    Expert Comment

    by:daffodils
    Look at the post.. the poster was using DreamWeaver too !

    He added Assembly reference in machine.config...
    <add assembly="System.DirectoryServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    Also, you can try using the fully qualified name as in put 'DirectoryServices.' before the objects in the code.


    0
     

    Author Comment

    by:NickMalloy
    so you would put

    <add assembly="System.DirectoryServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    at the top of the page or am I still confused.
    0
     
    LVL 8

    Accepted Solution

    by:
    No.. I was saying there two things:

    First in your code file:
    1. Remove the <%@ import Namespace="System.DirectoryServices" %> statement from the top.
    2. Write your code as:
    Dim objDE As New System.DirectoryServices.DirectoryEntry(CStr(Application("LDAP://CN=Users,DC=mydomain,DC=com")))

    .. IF the above still doesn't work, then
    1. Open machine.config and search for "System.DirectoryServices"
    2. If not found, then add the following line at the end of other <add assembly=......> statements.
    <add assembly="System.DirectoryServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    0
     

    Author Comment

    by:NickMalloy
    first one doesn't work. Where will I find machine.config?
    0
     
    LVL 8

    Expert Comment

    by:daffodils
    Should be under C:\WINNT\Microsoft.NET\Framework\v1.1.4322\CONFIG
    Or you can search for it on your computer.. there is only 1 per machine.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    913 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

    18 Experts available now in Live!

    Get 1:1 Help Now