我有一個連接到我的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