如何检查计算机的域帐户是否无效(信任已断开)? [英] How can I check whether the domain account of a computer got invalid (the trust is broken)?
本文介绍了如何检查计算机的域帐户是否无效(信任已断开)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须识别其域帐户
不再有效的笔记本。
I must recognize notebooks whose domain accounts
are no longer valid.
由于多个问题,可能会发生无效的域帐户。通常情况下,客户端已从备份还原,之后域帐户不再有效
Invalid domain accounts may happen due to several problems. Mostly the client got restored from a backup and afterwards the domain account is not valid any more
在这种情况下,行为是:
Int this case the behavour is:
- 用户的登录通过
缓存的凭据
- 用户
可以访问服务器上的共享($ LM)
和文件(NTLM) - 通过
Kerberos不能访问工作
- The user's logon works through
cached credentials
- The user
has access to shares
and files on the server (NTLM) - Access via
Kerberos does not work
是否有可能检查计算机帐户的有效性?
推荐答案
使用以下代码,我可以找到个无效的计算机域帐户
:
With this code I can find invalid computer domain accounts
:
try
{
string sMyComputer = "MyComputer"
Domain computerDomain = Domain.GetComputerDomain(); // may! throw ActiveDirectoryObjectNotFoundException if computer account is invalid
string sComputerDomain = computerDomain.Name;
NTAccount acc_machine = new NTAccount(sComputerDomain, sMyComputer + "$");
SecurityIdentifier sid = (SecurityIdentifier)acc_machine.Translate(typeof(SecurityIdentifier)); // always throws an SystemException if computer account is invalid
}
catch
{
// something is wrong with the account
}
- sMyComputer + $是帐户名称存储在活动目录中的方式
- 我的经验是,大多数情况下不会抛出第一个异常,并且返回值是计算机曾经具有正常工作的计算机帐户的域的正确名称
- 第二个异常如果computeraccount现在无效,则始终抛出(SystemException)。错误代码为80004005。(我曾期望过IdentityNotMappedException)
编辑:
更正了代码错误
corrected error in code
这篇关于如何检查计算机的域帐户是否无效(信任已断开)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文