执行ldap调用时出现COMException-error

本文关键字:COMException-error ldap 调用 执行 | 更新日期: 2023-09-27 18:10:24

相关代码:

    string ldapPath = Settings.Default.LDAPServer + Settings.Default.StartPath;
entry = new DirectoryEntry(ldapPath, username, password, AuthenticationTypes.None);
     `entry.Properties[propertyName]` // The exception is throwed at this line inside of 

GetAllOccurencesOfProperty -method

错误信息如下:

2013-04-23 13:55:44,895 ERROR [12] EPiServer.DataAbstraction.ScheduledJob.ExecuteStaticMethod - 3.1.2 Failed to execute job 94d9b172-591b-4893-8d29-1204b99cf8bd
System.Exception: CurrentPrincipal: eivind. LDAP: ldap://DC.opent_dom.local:389/. Error:System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
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 SSP.ADPhonebook.Job.LDAP.GetAllOccurencesOfProperty(DirectoryEntry entry, String propertyName) in C:'repo'products'EPiServer'src'trunk'SSP.ADPhonebook'Job'LDAP.cs:line 80
at SSP.ADPhonebook.Job.ADOUAndUserImport.Import.GetDirectoryEntryPage(DirectoryEntry entry) in C:'repo'products'EPiServer'src'trunk'SSP.ADPhonebook'Job'ADOUAndUserImport.cs:line 117
at SSP.ADPhonebook.Job.ADOUAndUserImport.Import.Execute() in C:'repo'products'EPiServer'src'trunk'SSP.ADPhonebook'Job'ADOUAndUserImport.cs:line 61
at SSP.ADPhonebook.Job.ADOUAndUserImport.Execute() in C:'repo'products'EPiServer'src'trunk'SSP.ADPhonebook'Job'ADOUAndUserImport.cs:line 31
at SSP.ADPhonebook.Job.ADOUAndUserImport.Execute() in C:'repo'products'EPiServer'src'trunk'SSP.ADPhonebook'Job'ADOUAndUserImport.cs:line 39

ldapPath: ldap://DC.opent_dom.local:389/OU=Rådmann,OU=Jevnaker Kommune,OU=brukere,DC=opent_dom,DC=local

我可以在ldap浏览器中浏览该地址

执行ldap调用时出现COMException-error

解决方案:ldap必须大写。我把ldap://DC.opent_dom.local:389/OU=Rådmann,OU=Jevnaker Kommune,OU=brukere,DC=opent_dom,DC=local改成

LDAP://DC.opent_dom.local:389/OU=Rådmann,OU=Jevnaker Kommune,OU=brukere,DC=opent_dom,DC=local