Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 390645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:59:05+00:00 2026-05-12T15:59:05+00:00

adding more info on @serialhobbyist’s request hi all. we’re (= me and my colleagues)

  • 0

adding more info on @serialhobbyist’s request

hi all. we’re (= me and my colleagues) using PrincipalContext from System.DirectoryServices.AccountManagement to retrieve some authentication info (make sure a user belongs to a group etc).

Important: our client is a service running as LocalSystem. this does not happen when we run in a normal process or when we change the service to run as a specific user

here’s a code sample:

using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domain))
{
    Principal p = Principal.FindByIdentity(ctx,IdentityType.Sid, sid);
    ...
}

normally all works well (getting replies).
once in a few hours (the trigger is not clear), or after a network disconnect and reconnect, (when our AD client disconnects, via network cable disconnect or VM adapter disable etc) we’re getting this exception:

System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred.

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.Principal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)

searched for the exception (0x80072020), I see it translates to LDAP_OPERATIONS_ERROR (actually used as a code value translation example here 🙂 )
we inspected the traffic using wireshark and the exception is thrown before any LDAP query is sent.
after re-starting our process everything is back to normal (can validate successfully, no exceptions).
can anybody shed light on the matter? any ideas how to achieve the equivalent the cleanups done on process termination?
thanks!

update: we’ve found a way around this, will supply answer below. however, we’d rather find a simpler solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:59:05+00:00Added an answer on May 12, 2026 at 3:59 pm

    we’ve found a workaround here on msdn, by querying LDAP directly using the DirectoryEntry + DirectorySearcher objects.
    this requires some rather nasty parsing (considering this ins’t our main speciality) instead of working via existing objects.
    using this approach however the condition described above isn’t encountered.
    as mentioned above, we would appreciate a better solution using the existing objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am adding more than one link button during runtime but they all have
I've not much response so am adding some more info. My buttons are not
Adding more than one child to a WPF StatusBar results in poor layout with
Is it possible that adding more import statements to your java code could slow
I had asked this question Adding more attributes to LINQ to SQL entity Now,
I've read several XSRF solutions that rely on adding more tokens to the response,
I'm not quite sure what field to use when adding more than 30 days
Adding source files more than one directory away (e.g. ../../source.cpp or ../../../somewhere_else/source.cpp, vs. just
Because of the more tedious way of adding hosts to be monitored in Nagios
I have a MyISAM table with more than 10^7 rows. When adding data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.