locked
LDAP Problem with .NET - Unknown error (0x80005000) RRS feed

  • Question

  • User-1409181380 posted

    I am trying to create a proof of concept to show how to connect to an LDAP
    server and how to search for values but I do not get anywhere. Here is what I
    have so far:

    Dim objEntry As DirectoryEntry
    Dim objSearcher As DirectorySearcher

    Try

    objEntry = New DirectoryEntry("ldap://www.openldap.com/dc=OpenLDAP,dc=org",
    Nothing, Nothing, AuthenticationTypes.Anonymous)

    objSearcher = New DirectorySearcher(objEntry, "(ou=People)")
    objSearchResult = objSearcher.FindOne()

    If Not objSearchResult Is Nothing Then
    'Do something
    End If

    Catch ex As Exception

    result.Text = ex.Message & vbNewLine & ex.Source

    End Try

    My code fails at the line:
    objSearchResult = objSearcher.FindOne()

    with the unhelpfu error of Unknown error (0x80005000)

    As you can see I use the www.openldap.com directory and I can connect
    anonymously using the Softeerra LDAP Browser 2.5

    Any help would be greatly appreciated 

    PS: I know there is already a similar thread (http://forums.asp.net/thread/1028020.aspx) but none of the suggested solutions work. Plus the proof of concept is a windows app, not a web app

    Thursday, September 14, 2006 7:15 PM

Answers

  • User-1409181380 posted

    Never mind - I might have figured it out. The problem was the following line:

    objEntry = New DirectoryEntry("ldap://www.openldap.com/dc=OpenLDAP,dc=org",Nothing, Nothing, AuthenticationTypes.Anonymous)

    No, the address is correct but it seems that the directoryEntry does not like it when the ldap:// part not all upper case. The entire code worked as soon as I changed i to:  LDAP://www.openldap.com/dc=OpenLDAP,dc=org. Plus the parameters for the user name and password should be set to an empty string and not nothing but I left them usually out anyway.

     But still, let me know if you see any other issues that I did not catch at this point.

     Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 15, 2006 12:36 AM

All replies

  • User-1409181380 posted

    Never mind - I might have figured it out. The problem was the following line:

    objEntry = New DirectoryEntry("ldap://www.openldap.com/dc=OpenLDAP,dc=org",Nothing, Nothing, AuthenticationTypes.Anonymous)

    No, the address is correct but it seems that the directoryEntry does not like it when the ldap:// part not all upper case. The entire code worked as soon as I changed i to:  LDAP://www.openldap.com/dc=OpenLDAP,dc=org. Plus the parameters for the user name and password should be set to an empty string and not nothing but I left them usually out anyway.

     But still, let me know if you see any other issues that I did not catch at this point.

     Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 15, 2006 12:36 AM
  • User1354132231 posted
    Yep, the provider is case sensitive as it tells ADSI how to behave - there are other ones too (e.g. WinNT, GC, Ads, IIS, NDS, etc.).  The most important one is LDAP really.
    Friday, September 15, 2006 11:35 AM
  • User-73514677 posted

    Hi..

    Please check this link: http://support.microsoft.com/default.aspx?scid=kb;en-us;329986

    Hope this helps for the Unknown error (0x80005000) Thank you

    Wednesday, March 19, 2008 6:13 AM
  • User1191518856 posted

    DirectoryServices error messages are seldomly funny ;-( 

    You can try to access the NativeObject of the DirectoryEntry to determine if authentication was successful. Try something like: 

    Dim value As Object
    value = objEntry.NativeObject
    
    If you do this right after you've created your DirectoryEntry (objEntry) then the value = ... should succeed if you are authenticated correctly, otherwise it will throw an Exception. If you start with this, then you should be able to determine if it is related to authentication problems.
    Wednesday, March 26, 2008 6:52 PM
  • User1843221445 posted

    The entire code worked as soon as I changed i to:  LDAP://www.openldap.com/dc=OpenLDAP,dc=org.
     

    Absolutely correct, this post is the ultimate answer, same thing happened with me and as soon i changed it to LDAP, every thing worked.

    Thanks for your help rimmey

    Thursday, February 4, 2010 5:19 AM
  • User1053201462 posted

    objEntry = New DirectoryEntry("ldap://www.openldap.com/dc=OpenLDAP,dc=org",
    Nothing, Nothing, AuthenticationTypes.Anonymous)

    objSearcher = New DirectorySearcher(objEntry, "(ou=People)")
    objSearchResult = objSearcher.FindOne()

    If Not objSearchResult Is Nothing Then
    'Do something
    End If 

     The Problem with the above code is The Connection string Your Using and Serach Filter

    Important Dont ever use small case for ldap,Use LDAP

    ldap://www.openldap.com/dc=OpenLDAP,dc=org

    Give Like This LDAP://IPadress of Domain Controller or Fully Qualified Domain/dc=OpenLDAP,dc=org",USerId,Password,AuthenticationTypes.Secure

    ex:LDAP://172.16.3.2/dc=OpenLDAP,dc=org",USerId,Password,AuthenticationTypes.Secure

    @Note:Give Service Account Userid or USerID which has access to Domain Controller and Password of the Account

     

    Dim adSearcher As New DirectorySearcher(adEntry)
    adSearcher.Filter = "(&(objectClass=user)(sAMAccountName=" & LoginID & "))"

    After the above code,load the Properpties Which u Need.

    objSearchResult = adSearcher.FindOne()

    LoginID is Give the UserId Which you Gave in above DirectoryEntry.

     

     

    Thursday, February 11, 2010 1:22 AM