Web Parts mess up my LDAP query RRS feed

  • Question

  • (Where does this cross disiplanary query belong?) :)

    I created a web-page that people can use to get a phone list. This web-page gets the information directly from LDAP. It works great.

    Now I've been asked to make it a web-part so that it can be installed into Sharepoint. I've gone through the web-part walkthrough (not being familiar with it) and I've no experience with Sharepoint so I have no idea what parts it really needs.

    So what was a web-page is now a web-control which I dragged into  a web-part zone-template. The aspx code is 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">


    The web page that is now a web-control is "PhoneListControl1". In it is the following code to perform the LDAP query.

    ' Set up our LDAP query
    objConnection = CreateObject("ADODB.Connection")
    objCommand = CreateObject("ADODB.COmmand")
    objConnection.Provider = "ADsDSOObject"
    ' objConnection.Properties("User ID") = "MyUserName"
    ' objConnection.Properties("Password") = "MyPassword"
    objConnection.Open("Active Directory Provider")
    objCommand.ActiveConnection = objConnection

    objCommand.CommandText = _
    "SELECT givenName,SN,telephoneNumber,mobile,facsimileTelephoneNumber," & _
    "extensionAttribute4,department,samAccountName, userAccountControl FROM " & _
    "'LDAP://MyLDAPServer" & _
    "WHERE objectCategory='User' AND objectClass = 'Person' AND " & Query

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

    When this phone list was just a web page, I did not need the two commented out lines above ("User ID", and "Password") to identify myself. Now that it's a web-part, I *DO* need those two lines.

    I'd rather not hard-code a dummy username and password into this code, but rather rely on the credentials of the person running this web-page to provide authorization.

    I realize that with web-parts, you have to do some authentication. Either a user list or windows authorization. I'm using windows authorization, but I think I'm missing something.

    Thursday, November 6, 2008 2:29 PM