Re: LDAP query on a web page

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



That sounds like the security issue I mentioned. Try adding some
credentials to your connection properties as per the ADSI docs and see if
that fixes it.

If so, then you either need to use some sort of hard-coded credentials or
fix the security model in your app so that the current security context can
bind to AD.

Note also that you may need to provide a domain hint in your path as well:

LDAP://mydomain.com/DC=mydomain,DC=com

Joe K.

"Stephan" <Stephan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85DCDC7B-CA76-4095-82E6-98D71D133EAA@xxxxxxxxxxxxxxxx
Thanks all for your help...
I am getting this error...

Provider error '80040e37'
Table does not exist.
/email.asp, line 47


Here is the codes that I am using...


<html>
<head>
<title></title>
</head>
<body>

<%@ Language=VBScript %>
<%
' connection and query variants
dim oRootDse,oConn,oComm,oRs
dim sADsPath,sFilter,sAttrs,sScope,sQuery
dim sUser

' instantiate connection objects and RootDSE
' (for pulling defaultNamingContext)
set oRootDse=getObject("LDAP://RootDSE";)
set oConn=createObject("ADODB.Connection")
set oComm=createObject("ADODB.Command")

' configure provider and define command
oConn.provider="ADsDSOObject"
oConn.open"Active Directory Provider"
oComm.activeConnection=oConn

' build query
sADsPath= "<LDAP://OU=Users,DC=mydomain,DC=com>;"
sFilter = "(&(objectCategory=person)(mail=*));"
sAttrs = "ADsPath;"
sScope = "SubTree"

sQuery = sADsPath&sFilter&sAttrs&sScope

' configure command properties
oComm.commandText=sQuery
oComm.properties("Page Size") =100
oComm.properties("Size Limit") =10000
oComm.properties("Cache Results") =false

' execute query
set oRs=oComm.execute

' check to see if query executed
if(isNull(oRs))then
' do nothing, as query yielded no results
else ' query was successful
if(not oRs.eOF)then ' check to see if any results
oRs.moveFirst ' were returned
while not oRs.eOF
' do something here
oRs.moveNext
wend
else ' empty record set (no results returned)
' handle error here
end if
end if
%>

</body>
</html>


Thanks Stephan



"Joe Kaplan (MVP - ADSI)" wrote:

It is pretty similar in ASP. It might be necessary to add a specific
server
name in the path and add specific credentials to the connection if the
security context in ASP cannot get to AD properly. Otherwise, it is the
same.

Joe K.

"Paul Williams [MVP]" <ptw2001@xxxxxxxxxxx> wrote in message
news:ersftqOWGHA.4452@xxxxxxxxxxxxxxxxxxxxxxx
Well, the LDAP query you want is (&(objectCategory=person)(mail=*))

How that's written in ASP I can't say. In VBS I'd do it something like
this:

' connection and query variants
dim oRootDse,oConn,oComm,oRs
dim sADsPath,sFilter,sAttrs,sScope,sQuery
dim sUser

' instantiate connection objects and RootDSE
' (for pulling defaultNamingContext)
set oRootDse=getObject("LDAP://RootDSE";)
set oConn=createObject("ADODB.Connection")
set oComm=createObject("ADODB.Command")

' configure provider and define command
oConn.provider="ADsDSOObject"
oConn.open"Active Directory Provider"
oComm.activeConnection=oConn

' build query
sADsPath= "<LDAP://"&oRootDse.get("defaultNamingContext")&">;"
sFilter = "(&(objectCategory=person)(mail=*));"
sAttrs = "ADsPath;"
sScope = "SubTree"

sQuery = sADsPath&sFilter&sAttrs&sScope

' configure command properties
oComm.commandText=sQuery
oComm.properties("Page Size") =100
oComm.properties("Size Limit") =10000
oComm.properties("Cache Results") =false

' execute query
set oRs=oComm.execute

' check to see if query executed
if(isNull(oRs))then
' do nothing, as query yielded no results
else ' query was successful
if(not oRs.eOF)then ' check to see if any results
oRs.moveFirst ' were returned
while not oRs.eOF
' do something here
oRs.moveNext
wend
else ' empty record set (no results returned)
' handle error here
end if
end if

--
Paul Williams
Microsoft MVP - Windows Server - Directory Services
http://www.msresource.net | http://forums.msresource.net







.



Relevant Pages

  • RE: ODBC query in VB code Need HELP
    ... terms of connection settings and object creation / disposal. ... Since your pass-through query already exists (including the ... Dim STRSQL As String ...
    (microsoft.public.access.formscoding)
  • RE: ODBC query in VB code Need HELP
    ... terms of connection settings and object creation / disposal. ... Since your pass-through query already exists (including the ... Dim STRSQL As String ...
    (microsoft.public.access.formscoding)
  • ADO Object in VB Script Only Calls SQLGetData for column 1
    ... I try I can only get the script to retrieve the first column of my query. ... Dim adoConnection As ADODB.Connection ... '—Build our connection string to use when we open the connection -- ...
    (microsoft.public.data.ado)
  • RE: Make Table from external DB Connection
    ... against that connection one time to get the temporary table formatted ... and then set up an Append query to populate the ... > into the access db while reading the records from oracle. ... > Dim oracle_db As New ADODB.Connection ...
    (microsoft.public.access.modulesdaovba)
  • Re: ADO Resource
    ... Do you get the error on the line you suggest that specifies the connection ... then it's purely a string concatenation ... Then I just put the security workgroup and security by using the wizard ... Dim Cnct As String, Src As String ...
    (microsoft.public.excel.programming)