Suddenly "Unknown error (0x8000500c)" is thrown when accessing Active Directory

1

I am running a WCF(.NET 3.5) service on IIS 7 in "domain1". The service runs under a domain user account from trusted domain "domain 2". The service is running on a different machine(virtual machine) from the machine(virtual machine) where "domain1" Domain Controller is running. The service was working properly in the production and then suddenly the following exception was thrown

Message: Unknown error (0x8000500c)System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Unknown error (0x8000500c) (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.Runtime.InteropServices.COMException: Unknown error (0x8000500c)

The above error was thrown by the following code:

private bool IsActiveDirectoryUser(string userName)
        {
            bool isActive = false;
            string[] userNameInfo = userName.Split(new char[] { '\\' });
            if (userNameInfo != null && userNameInfo.Length == 2)
            {
                string domainName = userNameInfo[0];
                string winName = userNameInfo[1];
                PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, domainName);
                PrincipalSearcher principalSearcher = null;
                {
                    UserPrincipal userPrincipal = new UserPrincipal(principalContext);
                    userPrincipal.SamAccountName = winName;
                    principalSearcher = new PrincipalSearcher(userPrincipal);
                    Principal principalUser = principalSearcher.FindOne();
                    if (principalUser != null)
                    {
                        UserPrincipal validUser = ((UserPrincipal)principalUser);
                        if ((validUser.Enabled != null && validUser.Enabled.Value) && !validUser.IsAccountLockedOut())
                            isActive = true;
                    }                    
                }
            }
            return isActive;
        }  

After restarting the service the exception was gone. I've tried to reproduce the error in the development environment but in vain. The online resources suggest two possible scenarios for generating 0x8000500c error:

  1. Accessing custom active directory attribute. I don't use this

  2. Problem with AD cashing. If this was the problem why the exception was gone after restarting the service. One would expect cache to be cleared after machine restarting not process restarting.

Any ideas on how to reproduce the error? Thanks!!

c#
wcf
active-directory
asked on Stack Overflow Aug 20, 2015 by whowhenhow • edited Aug 20, 2015 by Artem Kulikov

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0