当我们尝试通过获取属性 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”.
运行以下代码时,
using (var userEntry = new System.DirectoryServices.DirectoryEntry("WinNT://" + domain + '/' + user + ",user"))
{
DateTime expiryDate = (DateTime)userEntry.InvokeGet("PasswordExpirationDate");
答案 0 :(得分:0)
您是否检查了从 DirectoryEntry 获取的 userEntry 对象,以获取 PasswordExpirationDate ?