2

I'm using the AD authentication in my asp.net MVC solution. It's working in a local server, but when I publish it I get the error: "System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred.". Does anybody know what I have to do?

Leila
  • 318
  • 1
  • 4
  • 15

2 Answers2

2

Verify if you are publishing the dlls: System.DirectoryServices.dll and System.DirectoryServices.AccountManagement.dll.

Go to References in your web project, find both references, press f4 (properties tab), and set "Copy Local" to "True".

-- Added later

After, verify in your iis, if the setting "Asp.Net Impersonation" is enable. (Click in your web app in iis, and after, in Authorization icon)

Leila
  • 318
  • 1
  • 4
  • 15
Vinicius Ottoni
  • 4,631
  • 9
  • 42
  • 64
  • Verify in your iis, if the setting "Asp.Net Impersonation" is enable. (Click in your web app in iis, and after, in Authorization icon) – Vinicius Ottoni Feb 07 '12 at 18:30
1

I found this part of code and its works now:

 using (HostingEnvironment.Impersonate()) {
    // This code runs as the application pool user
         DirectorySearcher searcher ...
    }

http://sanjaymungar.blogspot.com/2010_07_01_archive.html or http://sharepoint-tweaking.blogspot.com/2007/12/impersonation-in-aspnet-causes.html

Ievgen
  • 4,261
  • 7
  • 75
  • 124