working with System.DirectoryServices

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?
NickMalloySystems LeadAsked:
Who is Participating?
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.

daffodilsCommented:
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
NickMalloySystems LeadAuthor Commented:
I am not using Visual studio for this project. I am simply using Dreamweaver MX
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

daffodilsCommented:
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
NickMalloySystems LeadAuthor Commented:
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
daffodilsCommented:
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

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
NickMalloySystems LeadAuthor Commented:
first one doesn't work. Where will I find machine.config?
0
daffodilsCommented:
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
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
ASP.NET

From novice to tech pro — start learning today.

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.