Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Runtime.InteropServices.COMException:在缓存中找不到目录属性_C#_Visual Studio - Fatal编程技术网

C# System.Runtime.InteropServices.COMException:在缓存中找不到目录属性

C# System.Runtime.InteropServices.COMException:在缓存中找不到目录属性,c#,visual-studio,C#,Visual Studio,当我们试图通过检索属性PasswordExpirationDate的值来检查本地用户帐户的密码是否过期时。它在某些环境中失败,出现异常-在缓存中找不到目录属性。 “An exception has occured and the exception is: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Run

当我们试图通过检索属性PasswordExpirationDate的值来检查本地用户帐户的密码是否过期时。它在某些环境中失败,出现异常-在缓存中找不到目录属性。

“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”.
运行以下代码时

使用(var userEntry=new System.DirectoryServices.DirectoryEntry(“WinNT://“+domain+'/'+user+”,user”))
{

DateTime expiryDate=(DateTime)userEntry.InvokeGet(“PasswordExpirationDate”);
是否检查了从DirectoryEntry获取的userEntry对象,以获取PasswordExpirationDate?

看起来像是错误的属性名称,它使用更直观的“pwdLastSet”查看其他代码;)脚本代码可能有助于查看角落案例。