Take the 2-minute tour ×

I am accessing user information from active directory. My code is working well on my local PC (having windows xp, not on domain). The code is

            PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domainName", "ActiveDirectoryID", "Password");

            UserPrincipal qbeUser = new UserPrincipal(ctx);
            PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
            qbeUser.SamAccountName = "AnyOther_AD_ID"; //To get any one's info
            foreach (var found in srch.FindAll())
                UserPrincipal foundUser = found as UserPrincipal;
                if (foundUser != null)
                    emailAddress = foundUser.EmailAddress;

But when i deploy my application to server pc (windows server 2003, on domain). It gives the error "The authentication mechanism is unknown". The question that strikes me is the server, that is on domain can not access AD info but my local pc, that is not on domain can access AD info (I am given AD_Id and Password).

share|improve this question
I am using windows authentication and set impersonate to true in web.config file. –  liaqat ali Dec 21 '11 at 13:48
add comment

1 Answer

up vote 0 down vote accepted

try providing login credentials for the user principle or searcher. I have experienced the same thing before and if I supplied my AD connection with a username & password it would work.

share|improve this answer
add comment

Your Answer


