我对C#中的Active Directory类有疑问。在我的程序中,我试图使用以下命令获取用户登录的当前域:
Domain.GetCurrentDomain();
大多数时候,它都有效。但是当从无线笔记本电脑执行时,它会给我以下错误:
System.DirectoryServices.ActiveDirectory.ActiveDirectoryServerDownException: The server is not operational.
Name: "DOMAIN.ca"
---> System.Runtime.InteropServices.COMException: The server is not operational.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
at System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName)
--- End of inner exception stack trace ---
at System.DirectoryServices.ActiveDirectory.PropertyManager.GetPropertyValue(DirectoryContext context, DirectoryEntry directoryEntry, String propertyName)
at System.DirectoryServices.ActiveDirectory.Domain.GetDomain(DirectoryContext context)
at System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain()
at ADT.ADTools.ComputerIsInDomain()
在我的特定情况下,这段代码应该适用于Active Directory帐户中记录的任何帐户,无论计算机运行的是什么计算机,或者计算机是否使用无线或有线连接连接到域。
你们中是否有人知道这个问题的答案,或者我能做些什么工作以使其发挥作用?
答案 0 :(得分:0)
我解决了这个问题。问题的根源是我们的业务网络内部。我做了几件事: