Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Windows 2008 R2 Web Server (test) which is added to Active Directory domain.

I have an application using AD searching features but, it does not work until I specify in code the credentials for an AD user.

Any idea how to configure the server to give it permissions for accessing AD? (I thought that adding it to domain will do that, however it hasn't.)

share|improve this question
up vote 1 down vote accepted

By default your application uses the account of the computer where your web server is installed to access AD and search should work in this case. But this behavior can be overridden by enabling impersonation in your application or specifying custom account for application pool that is used for your application.

Have you enabled impersonation or have your changed the application pool account?

share|improve this answer
.NET Impersonation was a way to go! THX! :-) – XXs Dec 22 '11 at 10:00
Uhm, it worked for a while and now it's giving mystic "Runtime Error" – XXs Dec 22 '11 at 10:04
Maybe you didn't dispose correctly resources. Do you use System.DirectoryServices namespace to search in AD? – begemot Dec 22 '11 at 10:11
Yes I use System.DirectoryServices. Well I don't think I dispose it bad way cause it works on IIs express localy, and on test server it runs well too if I specify my user and passowrd in DirectoryEntry constructor. – XXs Dec 22 '11 at 12:34
@XXs, I guess you are impersonating a fixed identity right now (, then you may consider disable impersonation and instead change the application pool identity to a domain account that has access to AD. After that you don't need to provide user and password in DirectoryEntry constructor. About the runtime error, it must be caused by another thing, which you should ask as a new question. – Lex Li Dec 27 '11 at 5:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.