none
System.Runtime.InteropServices.COMException: The directory property cannot be found in the cache. RRS feed

  • Question


  •  

    When we're trying to check if the local user account's password is expired, by retrieving the value of the property PasswordExpirationDate. It’s failing in some environments with exception - The directory property cannot be found in the cache”.

     

    An exception has occured and the exception is:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: The directory property cannot be found in the cache”.

     

     

    When running the below code,

     

    using (var userEntry = new System.DirectoryServices.DirectoryEntry("WinNT://" + domain + '/' + user + ",user"))

      {

    userEntry.RefreshCache();

          DateTime expiryDate = (DateTime)userEntry.InvokeGet("PasswordExpirationDate");

     

    If any of you have come across the same issue, request you to share your suggestion on the same.

     

    Monday, August 13, 2018 2:26 PM

All replies