473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

ldap connection problem

I am trying to connect to my college LDAP directory using ASP.NET. This LDap
does not have security as it returns only user demographic information.
i do not need to bind with a username or credentials.
What i am trying to do is, i am trying to look up all the information for
the user with user id 'testuser'. The following is the Vb.net code for my
aspx page:

Dim oRoot As DirectoryEntry = New
DirectoryEntry("LDAP://directory.x.y/ou=People,dc=x,dc=y")
Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
Dim oResult As SearchResult
Dim propName As String
Dim obProp As Object

Try
oSearcher.Filter = "uupid=testuser"
oResult = oSearcher.FindOne
For Each propName In oResult.Properties.PropertyNames
For Each obProp In oResult.Properties(propName)
Response.Write("name= " & propName)
Response.Write("value= " & obProp)
Next
Next
Catch Ex as Exception
End Try

The above code fails at the line "oResult = oSearcher.FindOne" and gives me
an error which is useless: "Unknown error (0x80005000)"
I have already posted this question twice. Is there nobody whos faced this
problem?
Please help me!! Thanks in advance.

Aug 2 '05 #1
7 6758
On Tue, 2 Aug 2005 06:11:05 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

§ I am trying to connect to my college LDAP directory using ASP.NET. This LDap
§ does not have security as it returns only user demographic information.
§ i do not need to bind with a username or credentials.
§ What i am trying to do is, i am trying to look up all the information for
§ the user with user id 'testuser'. The following is the Vb.net code for my
§ aspx page:
§
§ Dim oRoot As DirectoryEntry = New
§ DirectoryEntry("LDAP://directory.x.y/ou=People,dc=x,dc=y")
§ Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
§ Dim oResult As SearchResult
§ Dim propName As String
§ Dim obProp As Object
§
§ Try
§ oSearcher.Filter = "uupid=testuser"
§ oResult = oSearcher.FindOne
§ For Each propName In oResult.Properties.PropertyNames
§ For Each obProp In oResult.Properties(propName)
§ Response.Write("name= " & propName)
§ Response.Write("value= " & obProp)
§ Next
§ Next
§ Catch Ex as Exception
§ End Try
§
§ The above code fails at the line "oResult = oSearcher.FindOne" and gives me
§ an error which is useless: "Unknown error (0x80005000)"
§ I have already posted this question twice. Is there nobody whos faced this
§ problem?
§ Please help me!! Thanks in advance.

Sounds like it might be a credentials issue. What level of security is set for your web application
in IIS? Are you implementing impersonation?
Paul
~~~~
Microsoft MVP (Visual Basic)
Aug 2 '05 #2
Thank you for looking into the matter.
I tried implementing the primary token thing but it is of no avail.
Paul, currently my application is using "Anonymous" user on IIS and IIS
controls the password for the user. I also have the statement "<identity
impersonate="true"/>"
set in my web.config file.
What i dont understand is that the college ldap server required no
authentication and i can bind anonymously.
I really appreciate your help.Looking forward to your reply!
Thanks

"Paul Clement" wrote:
On Tue, 2 Aug 2005 06:11:05 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

¤ I am trying to connect to my college LDAP directory using ASP.NET. This LDap
¤ does not have security as it returns only user demographic information.
¤ i do not need to bind with a username or credentials.
¤ What i am trying to do is, i am trying to look up all the information for
¤ the user with user id 'testuser'. The following is the Vb.net code for my
¤ aspx page:
¤
¤ Dim oRoot As DirectoryEntry = New
¤ DirectoryEntry("LDAP://directory.x.y/ou=People,dc=x,dc=y")
¤ Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
¤ Dim oResult As SearchResult
¤ Dim propName As String
¤ Dim obProp As Object
¤
¤ Try
¤ oSearcher.Filter = "uupid=testuser"
¤ oResult = oSearcher.FindOne
¤ For Each propName In oResult.Properties.PropertyNames
¤ For Each obProp In oResult.Properties(propName)
¤ Response.Write("name= " & propName)
¤ Response.Write("value= " & obProp)
¤ Next
¤ Next
¤ Catch Ex as Exception
¤ End Try
¤
¤ The above code fails at the line "oResult = oSearcher.FindOne" and gives me
¤ an error which is useless: "Unknown error (0x80005000)"
¤ I have already posted this question twice. Is there nobody whos faced this
¤ problem?
¤ Please help me!! Thanks in advance.

Sounds like it might be a credentials issue. What level of security is set for your web application
in IIS? Are you implementing impersonation?
Paul
~~~~
Microsoft MVP (Visual Basic)

Aug 2 '05 #3
Have you tried using ADSIEdit or ADSIView yet? (Does it work?)
Does this work in a console app?
Is your LDAP string is correct?
Is " LDAP://directory.x.y/ou=People,dc=x,dc=y" the actual LDAP string?
Is the IIS server trusted at the respective domain you're trying to
search?
Have you tried filtering using another property (like SAMAccountName)?

I am sure after answering these questions someone will be able to help.
You can also try using DirectoryEntry("LDAP...", null, null,
AutheticationTypes.Secure);
Erick Sgarbi
www.blog.csharpbox.com

"Amar" <Am**@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com:
Thank you for looking into the matter.
I tried implementing the primary token thing but it is of no avail.
Paul, currently my application is using "Anonymous" user on IIS and IIS
controls the password for the user. I also have the statement "<identity
impersonate="true"/>"
set in my web.config file.
What i dont understand is that the college ldap server required no
authentication and i can bind anonymously.
I really appreciate your help.Looking forward to your reply!
Thanks

"Paul Clement" wrote:
On Tue, 2 Aug 2005 06:11:05 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

§ I am trying to connect to my college LDAP directory using ASP.NET. This LDap
§ does not have security as it returns only user demographic information.
§ i do not need to bind with a username or credentials.
§ What i am trying to do is, i am trying to look up all the information for
§ the user with user id 'testuser'. The following is the Vb.net code for my
§ aspx page:
§
§ Dim oRoot As DirectoryEntry = New
§ DirectoryEntry("LDAP://directory.x.y/ou=People,dc=x,dc=y")
§ Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
§ Dim oResult As SearchResult
§ Dim propName As String
§ Dim obProp As Object
§
§ Try
§ oSearcher.Filter = "uupid=testuser"
§ oResult = oSearcher.FindOne
§ For Each propName In oResult.Properties.PropertyNames
§ For Each obProp In oResult.Properties(propName)
§ Response.Write("name= " & propName)
§ Response.Write("value= " & obProp)
§ Next
§ Next
§ Catch Ex as Exception
§ End Try
§
§ The above code fails at the line "oResult = oSearcher.FindOne" and gives me
§ an error which is useless: "Unknown error (0x80005000)"
§ I have already posted this question twice. Is there nobody whos faced this
§ problem?
§ Please help me!! Thanks in advance.

Sounds like it might be a credentials issue. What level of security is set for your web application
in IIS? Are you implementing impersonation?
Paul
~~~~
Microsoft MVP (Visual Basic)


Aug 2 '05 #4
Have you tried using ADSIEdit or ADSIView yet? (Does it work?)
---Yes i tried connecting using ldp.exe and it does work. Since it does not
require a username and password to connect it allows me to connect and shows
me search values if i do a search.

Does this work in a console app?
---I tried doing a desktop application using Vb.net. Gives me the same error
that i get through a web application. It bombs out at the line
osearcher.FindOne with the same stupid error "Unknown Error(0x80005000)"
Is your LDAP string is correct? ---My LDAP String is correct i believe because i used the same string in the
windows support tool application ldp.exe as mentioned above and it works.
Probably i am not using it in the right format in my asp.net application and
you could guide me there. I have mentioned what i use in my first question to
which you replied
Is " LDAP://directory.x.y/ou=People,dc=x,dc=y" the actual LDAP string? --- No this is just an example string. I have some values for x and y that
correspond to my ldap server. I can tell u these if you want.
Is the IIS server trusted at the respective domain you're trying to
search? ---I dont know because the LDAP server is on the college campus servers and
i have no access to that server. Also, as per your suggestion it should not
matter because if a desktop application should work then i dont need a web
application and we can leave IIS out of this.
Have you tried filtering using another property (like SAMAccountName)? --- I thought this property could only be used for windows 95,98,NT4
machines. If i am wrong please post an example with the use of this property.
I will appreciate that.
You can also try using DirectoryEntry("LDAP...", null, null,
AutheticationTypes.Secure); ---I tried using that. Still the same problem. Also as i mentioned i dont
need to use authenticationtypes.secure because i can bind anonymously to this
ldap server thats what the campus people who have this server tell me.

Please help me!! Thanks for all your help till now. I really appreciate your
looking into this problem. Looking forward to your reply.

"Erick Sgarbi" wrote:
Have you tried using ADSIEdit or ADSIView yet? (Does it work?)
Does this work in a console app?
Is your LDAP string is correct?
Is " LDAP://directory.x.y/ou=People,dc=x,dc=y" the actual LDAP string?
Is the IIS server trusted at the respective domain you're trying to
search?
Have you tried filtering using another property (like SAMAccountName)?

I am sure after answering these questions someone will be able to help.
You can also try using DirectoryEntry("LDAP...", null, null,
AutheticationTypes.Secure);
Erick Sgarbi
www.blog.csharpbox.com

"Amar" <Am**@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com:
Thank you for looking into the matter.
I tried implementing the primary token thing but it is of no avail.
Paul, currently my application is using "Anonymous" user on IIS and IIS
controls the password for the user. I also have the statement "<identity
impersonate="true"/>"
set in my web.config file.
What i dont understand is that the college ldap server required no
authentication and i can bind anonymously.
I really appreciate your help.Looking forward to your reply!
Thanks

"Paul Clement" wrote:
On Tue, 2 Aug 2005 06:11:05 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

¤ I am trying to connect to my college LDAP directory using ASP.NET. This LDap
¤ does not have security as it returns only user demographic information.
¤ i do not need to bind with a username or credentials.
¤ What i am trying to do is, i am trying to look up all the information for
¤ the user with user id 'testuser'. The following is the Vb.net code for my
¤ aspx page:
¤
¤ Dim oRoot As DirectoryEntry = New
¤ DirectoryEntry("LDAP://directory.x.y/ou=People,dc=x,dc=y")
¤ Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
¤ Dim oResult As SearchResult
¤ Dim propName As String
¤ Dim obProp As Object
¤
¤ Try
¤ oSearcher.Filter = "uupid=testuser"
¤ oResult = oSearcher.FindOne
¤ For Each propName In oResult.Properties.PropertyNames
¤ For Each obProp In oResult.Properties(propName)
¤ Response.Write("name= " & propName)
¤ Response.Write("value= " & obProp)
¤ Next
¤ Next
¤ Catch Ex as Exception
¤ End Try
¤
¤ The above code fails at the line "oResult = oSearcher.FindOne" and gives me
¤ an error which is useless: "Unknown error (0x80005000)"
¤ I have already posted this question twice. Is there nobody whos faced this
¤ problem?
¤ Please help me!! Thanks in advance.

Sounds like it might be a credentials issue. What level of security is set for your web application
in IIS? Are you implementing impersonation?
Paul
~~~~
Microsoft MVP (Visual Basic)


Aug 3 '05 #5
On Tue, 2 Aug 2005 12:31:06 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

§ Thank you for looking into the matter.
§ I tried implementing the primary token thing but it is of no avail.
§ Paul, currently my application is using "Anonymous" user on IIS and IIS
§ controls the password for the user. I also have the statement "<identity
§ impersonate="true"/>"
§ set in my web.config file.
§ What i dont understand is that the college ldap server required no
§ authentication and i can bind anonymously.
§ I really appreciate your help.Looking forward to your reply!
§ Thanks

You might have some problem accessing Active Directory with the Anonymous account, since it's a
least privileged account.

Can you use Basic or Integrated Windows authentication with a domain account and impersonation? If
not, you may need to run this web application under an account that has sufficient privileges for
Active Directory access.
Paul
~~~~
Microsoft MVP (Visual Basic)
Aug 3 '05 #6
Thanks again Paul. I tried using the impersonation parameter into the
web.config file, also tried using a domain user account to run the web
application under but no use.
Sorry, but nothing just seems to work! The following is the error and the
stack.
Unknown error (0x80005000) at
System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail) at
System.DirectoryServices.DirectoryEntry.Bind() at
System.DirectoryServices.DirectoryEntry.get_AdsObj ect() at
System.DirectoryServices.DirectorySearcher.FindAll (Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne ()

Thanks,
Amar

"Paul Clement" wrote:
On Tue, 2 Aug 2005 12:31:06 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

¤ Thank you for looking into the matter.
¤ I tried implementing the primary token thing but it is of no avail.
¤ Paul, currently my application is using "Anonymous" user on IIS and IIS
¤ controls the password for the user. I also have the statement "<identity
¤ impersonate="true"/>"
¤ set in my web.config file.
¤ What i dont understand is that the college ldap server required no
¤ authentication and i can bind anonymously.
¤ I really appreciate your help.Looking forward to your reply!
¤ Thanks

You might have some problem accessing Active Directory with the Anonymous account, since it's a
least privileged account.

Can you use Basic or Integrated Windows authentication with a domain account and impersonation? If
not, you may need to run this web application under an account that has sufficient privileges for
Active Directory access.
Paul
~~~~
Microsoft MVP (Visual Basic)

Aug 3 '05 #7
Thanks Paul. I think i solved the problem. Here's how i did it:
1. I passed the filter but without the "ou=people" in the Ldap path
(LDAP://directory.x.y/dc=x,dc=y)
2. This returned the uid from the server.
3. i then built the ldap path again with the necessary DN, hence the final
ldap path was
LDAP://directory.x.y/uid=12345,ou=People,dc=x,dc=y

Thanks for all your efforts Paul

"Paul Clement" wrote:
On Tue, 2 Aug 2005 12:31:06 -0700, "Amar" <Am**@discussions.microsoft.com> wrote:

¤ Thank you for looking into the matter.
¤ I tried implementing the primary token thing but it is of no avail.
¤ Paul, currently my application is using "Anonymous" user on IIS and IIS
¤ controls the password for the user. I also have the statement "<identity
¤ impersonate="true"/>"
¤ set in my web.config file.
¤ What i dont understand is that the college ldap server required no
¤ authentication and i can bind anonymously.
¤ I really appreciate your help.Looking forward to your reply!
¤ Thanks

You might have some problem accessing Active Directory with the Anonymous account, since it's a
least privileged account.

Can you use Basic or Integrated Windows authentication with a domain account and impersonation? If
not, you may need to run this web application under an account that has sufficient privileges for
Active Directory access.
Paul
~~~~
Microsoft MVP (Visual Basic)

Aug 3 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MickBim | last post by:
Hi, I'm developping a module in PHP to get the users of a LDAP server and add them in a Postgre database, where normal users are too. I've managed to do this "easily" but now a new problem...
1
by: ngiven | last post by:
Dear PHP Programmers, Here is what I have: PHP Version 4.3.8 LDAP Support enabled RCS Version $Id: ldap.c,v 1.130.2.10 2004/06/01 21:05:33 iliaa Exp $ Total Links 0/unlimited API Version...
5
by: Bryan | last post by:
Hello, I have a asp.net app working with directory services on my Windows XP development machine. However when I moved the application over to our production server (Win 2000 Server) it no longer...
7
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or...
1
by: LDAP Connection stays open | last post by:
Howzit. I am currenlty using .NET C# to connect to the normal eDirectory tree to auth users. My code is 3 lines long, using the Novell LDAP/C# API examples. The code work 100% and the users...
4
by: Terry Miller | last post by:
I have DB2 V8.2 loaded on a Redhat Enterprise Linux version 3 (RHEL 3) box. RHEL is configured to talk to LDAP for authenticaton besides the local passwd file. I can verify this by executing an su...
1
by: Steve JORDI | last post by:
Hi, it seems to me that I have a problem using an LDAPS connection to our server for identification purposes (using OpenLDAP and OpenSSL). Using PHP 4.4.4 I have the following code which...
0
by: sbartz | last post by:
Greetings, My ldap application relies on user input for a ldap server uri, so I am looking for a way to use the ldap api to determine whether the ldap server is up or not. All the docs have to...
2
by: schtroumfps | last post by:
Hi, I have developed an internal application in ASP.NET 2.0/C# that is using an LDAP connection. Basically, I am getting the LDAP users to match some userís roles and rights that I have in SQL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.