Re: LDAP query on a web page
- From: "Joe Kaplan \(MVP - ADSI\)" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 6 Apr 2006 14:53:30 -0500
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
.
- Follow-Ups:
- Re: LDAP query on a web page
- From: Stephan
- Re: LDAP query on a web page
- References:
- Re: LDAP query on a web page
- From: Joe Kaplan \(MVP - ADSI\)
- Re: LDAP query on a web page
- From: Paul Williams [MVP]
- Re: LDAP query on a web page
- From: Joe Kaplan \(MVP - ADSI\)
- Re: LDAP query on a web page
- From: Stephan
- Re: LDAP query on a web page
- Prev by Date: Re: AD SSL, what impact?
- Next by Date: Re: PDC maintains the last two (2) user passwords in AD
- Previous by thread: Re: LDAP query on a web page
- Next by thread: Re: LDAP query on a web page
- Index(es):
Relevant Pages
|