Search code examples
active-directorycompiler-errorsasp.net-3.5directoryservices

System.DirectoryServices compilation problems


I'm using the code here : ASP.NET How to get List of Groups in Active Directory

Specifically :

using System.DirectoryServices;

DirectoryEntry objADAM = default(DirectoryEntry); //compiler error!

Problem: compiler says that it doesn't know what DirectoryEntry is.

I tried to add it to my web.config:

      <assemblies>
          <!-- ... -->
          <add assembly="System.DirectoryServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>

But it didn't seem to help so I tried to add a reference:

enter image description here

Someone suggested setting Copy Local = True but that didn't help either.

I noticed that I don't see a reference for System.DirectoryServices - only System.DirectoryServices.Accountmanagement

enter image description here

Can anyone help me get this code to compile? I'm not sure what to try next.


Solution

  • Take the .net 3.5 filter off in the Add Reference dialog, and then put a reference in your project to:

    System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

    You can take the filter off by changing you project setting : http://msdn.microsoft.com/en-us/library/bb398202.aspx