我有一个连接到我的LDAP的问题。它不断给我一个COMExceptionError(参数不正确)LDAP连接错误
这里是我的代码至今:
static void Main(string[] args)
{
DirectoryEntry ldapConnection = new DirectoryEntry("10.9.130.113:667");
ldapConnection.Path = "LDAP://ou=Users,ou=CorporateStore,ou=Absa,c=za";
ldapConnection.AuthenticationType = AuthenticationTypes.Anonymous;
DirectorySearcher ds = new DirectorySearcher(ldapConnection);
SearchResult result = ds.FindOne();
Console.ReadLine();
if (result != null)
{
ResultPropertyCollection fields = result.Properties;
foreach (String ldapField in fields.PropertyNames)
{
foreach (Object myCollection in fields[ldapField])
Console.WriteLine(String.Format("{0,-20} : {1}",
ldapField, myCollection.ToString()));
Console.ReadLine();
}
这是在发生错误的行:
SearchResult result = ds.findOne();
继承人异常错误和堆栈跟踪:
System.Runtime.InteropServices.COMException was unhandled
Message=The parameter is incorrect.
Source=System.DirectoryServices
ErrorCode=-2147024809
StackTrace:
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
at LDAPConnector.Program.Main(String[] args) in c:\documents and settings\expn261\my documents\visual studio 2010\Projects\LDAPConnector\LDAPConnector\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
任何想法?
以及哪一行给出错误?你能包含异常细节和堆栈跟踪吗? –
除了@Davide Piras的问题。这是AD还是另一台LDAP服务器? – Vader
是的,即时连接到远程机器,这是一个ldap服务器。我正在使用的机器在同一个网络/域上 – Trishen