Leila
Leila

Reputation: 328

Error on publishing: System.DirectoryServices.DirectoryServicesCOMException

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?

Upvotes: 2

Views: 4411

Answers (2)

Ievgen
Ievgen

Reputation: 4443

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

Upvotes: 1

Vinicius Ottoni
Vinicius Ottoni

Reputation: 4677

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)

Upvotes: 2

Related Questions