Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIS integraded user and ASP query LDAP

Status
Not open for further replies.

jim6786

Technical User
Nov 19, 2010
2
I've read so many LDAP querying wish ASP forms that I am unsure why my code isn't working...I am getting the notorious Table does not exist when running a vbscript under ASP.

My code should return the following users Full Name based on their username they are logged in as. The code is copied from a vbscript i made in notepad. If executed on my local machine via the vbs file the script does exactly what i want. However when i convert it to ASP/VBSCript code on the IIS box it fails. Spitting out:
Code:
Provider error '80040e37' 

Table does not exist.

My IIS settings are:
Authenitcation = Integrated Windows Authenitcation, anonymous user=off
IIS server is part of the domain
any non-privledged user can run the script file and get the desired results

Code:
<%
dim currentUser, mySessionID, sessionUser, sessionUserFN
sessionUser = Request.ServerVariables("LOGON_USER")
%>
<%language=vbscript%>
<%
'grab name based on currentUser
	Set objectAD = GetObject("LDAP://RootDSE")
	strLDAP= objectAD.Get("defaultNamingContext") ' top level of Domain

	
	Set adoCommand = CreateObject("ADODB.Command")
	Set adoConnection = CreateObject("ADODB.Connection")

	adoConnection.Open "Provider=ADsDSOObject;"
	adoCommand.ActiveConnection = adoConnection
	adoCommand.CommandText= "SELECT givenName, SN, mail FROM 'LDAP://" & strLDAP & "' WHERE samAccountName='" & sessionUser & "'"

	
	'execute command and return recordSet
	Set objRecordSet = adoCommand.Execute

	'deal with results from query
	if objRecordSet.RecordCount > 0 Then
		objRecordSet.MoveFirst
		'convert to lastname, firstname
	
		sessionUserFN = objRecordSet.Fields("SN").Value &","& objRecordSet.Fields("givenName").Value &"   "& objRecordSet.Fields("mail").Value
		
	Else
		
	End If

	adoConnection.Close

mySessionID = Session.SessionID

Response.Write ("<div align='right'>Welcome user " & sessionUserFN & "</div>")
%>

From my understanding of Windows Integrated Authentication in IIS...IIS should be executing this script as the user hitting the web page...

The webbox bombs on
Code:
Set objRecordSet = adoCommand.Execute

Any help would be greatly appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top