Web Parts messing with my LDAP query

Web Parts messing with my LDAP query

Post by TWFyayBDIE » Fri, 07 Nov 2008 06:19:02

Forgive me if this isn't the correct area to post this. The problem deals with

Visual Studio Web page development
LDAP queries

I developed a web page that works great. It searches and grabs phone numbers
via LDAP. The code in question;

objCommand.CommandText = _
givenName,SN,telephoneNumber,mobile,facsimileTelephoneNumber," & _
userAccountControl FROM " & _
"'LDAP://dc=mydc,dc=myorg' " & _
"WHERE objectCategory='User' AND objectClass = 'Person' AND " &

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objRecordSet = objCommand.Execute

After I completed the web-page, I was asked to see if I could place it
within a web-part so that it can be integrated into Sharepoint. (Not familiar
with either)

I made a web-control (phoneListContol.ascx) where the form and above VB code

I then dragged the control to the a web-part template on my main page. Code
as follows...

<form id="form1" runat="server">
<br />
<asp:WebPartManager ID="WebPartManager1" runat="server">
<asp:WebPartZone ID="Main" runat="server">
<uc1:PhoneListControl id="PhoneListControl1" runat="server">


When I execute the page and it comes to the VB line;

objRecordSet = objCommand.Execute

it dies saying "Table not found"

I think this might be a security thing, but it's driving me nuts.

Web Parts messing with my LDAP query

Post by TWFyayBDIE » Fri, 07 Nov 2008 23:18:21

A little more info.

Above the first line of VB code below are the following lines;

objConnection = CreateObject("ADODB.Connection")
objCommand = CreateObject("ADODB.COmmand")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "MyUserName"
objConnection.Properties("Password") = "MyPasswod"
objConnection.Open("Active Directory Provider")
objCommand.ActiveConnection = objConnection

What wasn't there before were the "User ID" and "Password" lines. With these
lines, the code works.

Now my question is, why if this were just a plain web-page without web-parts
would this code work without identifying myself, but when I place it into a
web-part, it DOES require me to identify myself. I don't want to hard-code a
dummy username and password into this routine. How do I get the web-parts to
assume the person running the page is the credentials it should be using?