在尝试查询 AD 服务器之前,我想检查它是否还活着并且正在运行.看起来是一件微不足道的事情,但我还没有找到任何可以解释这一点的东西.
Before trying to query the AD server I would like to check if it is alive and kicking. Looks like a trivial thing, but I havent found anything to elucidate this.
我该怎么做?
我只是尝试获取与正在运行的用户关联的当前域上下文:
I just try to get the current domain context associated with the running user:
try {
var domain = Domain.GetCurrentDomain();
/* Whatever i need from the domain */
} catch(ActiveDirectoryOperationException ex) {
MessageBox.Show("Cannot contact AD Server");
}
<小时>
如果你想连接到另一个域,你可以尝试:
If you want to connect to another domain you can try:
try {
var domain = Domain.GetDomain(
new DirectoryContext(DirectoryContextType.Domain, "mydomain.local"));
/* Whatever i need from the domain */
} catch(ActiveDirectoryOperationException ex) {
MessageBox.Show("Cannot contact AD Server");
}
这篇关于如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!