.Net ComException while calling UserPrincipal.FindByIdentity (0x80005000)

0

Our Application is using .Net Web API which is running on IIS 8. For past few days exactly 8 AM(i.e.. the time user starts to access the application) we are getting the below exception while trying the get the User Identity. It's works after App Pool Refresh and till next day we don't see any exception. Can someone help me on this.

System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_AdsObject()
   at System.DirectoryServices.PropertyValueCollection.PopulateList()
   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
   at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
   at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
   at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
   at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue)
   at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)

Code :

using (var user = UserPrincipal.FindByIdentity(UserPrincipal.Current.Context, IdentityType.SamAccountName, userName) ??

                              UserPrincipal.FindByIdentity(UserPrincipal.Current.Context, IdentityType.UserPrincipalName, userName))

            {
                return user == null ? null : new WindowsIdentity(user.UserPrincipalName);
            }
c#
.net
iis
userprincipal
asked on Stack Overflow Oct 2, 2019 by Max_dev • edited Oct 4, 2019 by Max_dev

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0