2
Answers

Getting error in my LDAP query

Ask a question
snufse

snufse

14y
6.9k
1


Using vb2005 and trying to query LDAP from code behind:

 
Dim prefixText As String = "vg"
Dim cn As New Data.OleDb.OleDbConnection("Provider=ADSDSOObject")
Dim cmd As Data.OleDb.OleDbCommand = cn.CreateCommand()
cmd.CommandText = "select sAMAccountName, displayName, title, userAccountControl from 'LDAP://DC=Vecelliogroup,DC=COM' where objectCategory = 'User' and title <> ' ' and (userAccountControl <> '66050' and userAccountControl <> '514') and sAMAccountName like '%" & prefixText & "%'"
Try
            Dim da As New Data.OleDb.OleDbDataAdapter(cmd)
            da.Fill(mySqlDataTable)

Value of my select string is: select sAMAccountName, displayName, title, userAccountControl from 'LDAP://DC=Vecelliogroup,DC=COM' where objectCategory = 'User' and title <> ' ' and (userAccountControl <> '66050' and userAccountControl <> '514') and sAMAccountName like '%vg%'

Getting error:

System.Data.OleDb.OleDbException: 'ADSDSOObject' failed with no error message available, result code: DB_E_ERRORSINCOMMAND(0x80040E14).

Now, if I leave out the "title" and the "sAMAccountName" from my select query it works fine. I am trying to get records where the "title" is not empty and name matches my prefix.

Answers (2)