Results 1 to 8 of 8

Thread: LDAP Query

Threaded View

  1. #1

    Thread Starter
    Fanatic Member snufse's Avatar
    Join Date
    Jul 2004
    Location
    Jupiter, FL
    Posts
    912

    Question LDAP Query

    I have created a sp querying LDAP such as:


    Code:
    ALTER PROCEDURE [dbo].[sp_LDAP_Query] 
    
    as  
    
    set nocount on
    
    select  * 
    from  openquery(ADSI, ' 
    select  title, sAMAccountName, displayName, userAccountControl
    from    ''LDAP://DC=xxx,DC=COM'' 
    where   objectCategory = ''User''') 
    where title is not null and (userAccountControl <> '66050' and userAccountControl <> '514')
    order by displayName
    I sign on to Sequel Server 2005 in Windows Authentication mode and execute the sp:

    Code:
    exec vecellio.dbo.sp_LDAP_Query
    A result set is returned. So far, so good.


    Now in ASP I have a connection string like:


    Code:
    <add key="ConnectionString" value="Data Source=VGIBESQL;Initial Catalog=XXX;Integrated Security=SSPI;"/>
    also using Windows Authentication and code to call the same sp:


    Code:
    If mySqlConnection.State = Data.ConnectionState.Closed Then
                mySqlConnection.Open()
            End If
    
            Try
                mySqlCommand.Connection = mySqlConnection
                mySqlCommand.CommandType = Data.CommandType.StoredProcedure
                mySqlCommand.CommandText = ("vecellio.dbo.sp_LDAP_Query")
                mySqlCommand.Connection = mySqlConnection
                mySqlDataAdapter.SelectCommand = mySqlCommand
                mySqlDataAdapter.Fill(mySqlDataTable)
                Session("myMenuDataTable") = mySqlDataTable
            Catch ex As Exception
                Message = ex.ToString
                myError = True
            End Try
    Now I get error on the "mySqlCommand.ExecuteScalar()" line:



    Code:
    System.Data.SqlClient.SqlException: An error occurred while preparing the query " 
    select  title, sAMAccountName, displayName, userAccountControl
    from    'LDAP://DC=Vecelliogroup,DC=COM' 
    where   objectCategory = 'User'" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".
    Any ideas???
    Last edited by snufse; Feb 8th, 2010 at 07:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width