Question

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).

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top