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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Example of ASP LDAP query string? 14

Status
Not open for further replies.

MikeBronner

Programmer
May 9, 2001
756
US
Could someone post an example of ASP code used to query LDAP without any proprietary components?

Thanks! Take Care,
Mike
 
Please post the asp that you do have that does display the username.
 
The code that displays the username is:

<%
Dim strNTUser, iPos
strNTUser = RTrim(Request.ServerVariables(&quot;LOGON_USER&quot;))
iPos = Len(strNTUser) - InStr(1, strNTUser,&quot;\&quot;,1)
strNTUser = Right(strNTUser, iPos)
Response.Write(strNTUSer)
%>

(To function, this requires turning off anonymous access in IIS for the folder this ASP is in. A design feature, according to MS. This particular code example above parses out the domain name of the username.)

And the ASP code is:

<html>

<head>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;en-us&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 5.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<title>Add Change</title>

<script language=&quot;JavaScript&quot; src=&quot;../scripts/calendar.js&quot;></script>

</head>

<body topmargin=&quot;0&quot; leftmargin=&quot;0&quot;>

<table border=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; height=&quot;4%&quot; id=&quot;AutoNumber3&quot; bgcolor=&quot;#000080&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot;>
<tr>
<td width=&quot;100%&quot; height=&quot;25&quot;>
<p align=&quot;center&quot;><font face=&quot;Arial Unicode MS&quot; size=&quot;5&quot; color=&quot;#FFFFFF&quot;>
Change Management</font></td>
</tr>
</table>
<div align=&quot;center&quot;>
<center>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;593&quot; height=&quot;90%&quot; id=&quot;AutoNumber5&quot;>
<tr>
<td width=&quot;593&quot; height=&quot;9&quot; colspan=&quot;4&quot;>
<p align=&quot;center&quot;>
<font face=&quot;Arial Unicode MS&quot; size=&quot;4&quot;>Enter New Change</font></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;><b>
Request Number:</b></font></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<font size=&quot;1&quot; face=&quot;Arial Unicode MS&quot;>(chosen from db, displayed automatically)</font></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Requestor:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<span style=&quot;vertical-align: middle&quot;><font face=&quot;Arial Unicode MS&quot; size=3>
<!-- solution from -->
<!-- displays: DOMAIN\usernam e-->
<!-- <%Response.Write(Request.ServerVariables(&quot;auth_user&quot;))%> -->
<!-- To display only the username... -->
<%
Dim strNTUser, iPos
strNTUser = RTrim(Request.ServerVariables(&quot;LOGON_USER&quot;))
iPos = Len(strNTUser) - InStr(1, strNTUser,&quot;\&quot;,1)
strNTUser = Right(strNTUser, iPos)
Response.Write(strNTUSer)
%>

</font></span>
</td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
E-mail:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<font size=&quot;1&quot; face=&quot;Arial Unicode MS&quot;>(autofill based on login)</font></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Status:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><input type=&quot;text&quot; name=&quot;enterStatus&quot; size=&quot;20&quot; style=&quot;float: left&quot;></td>
</tr>
<tr>
<td width=&quot;593&quot; height=&quot;9&quot; colspan=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Server Name:</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot;>
<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot; onSubmit=&quot;&quot;>
<!--webbot bot=&quot;SaveResults&quot; u-file=&quot;../_private/form_results.csv&quot; s-format=&quot;TEXT/CSV&quot; s-label-fields=&quot;TRUE&quot; startspan --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;0&quot;><!--webbot bot=&quot;SaveResults&quot; endspan i-checksum=&quot;43374&quot; --><p>
<input type=&quot;text&quot; name=&quot;enterServer&quot; size=&quot;20&quot; style=&quot;float: left&quot;></p>
</form>
</td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Production?
(Y/N):</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot;>
<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot; onSubmit=&quot;return FrontPage_Form2_Validator(this)&quot; language=&quot;JavaScript&quot; name=&quot;FrontPage_Form2&quot;>
<!--webbot bot=&quot;SaveResults&quot; u-file=&quot;../_private/form_results.csv&quot; s-format=&quot;TEXT/CSV&quot; s-label-fields=&quot;TRUE&quot; startspan --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;1&quot;><!--webbot bot=&quot;SaveResults&quot; endspan i-checksum=&quot;43406&quot; --><p>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><select size=&quot;1&quot; name=&quot;D1&quot; style=&quot;float: left&quot;>
<option>Yes</option>
<option>No</option>
</select></p>
</form>
</td>
</tr>
<tr>
<td width=&quot;163&quot; height=&quot;4&quot; colspan=&quot;3&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Description Of Change:</font></b></td>
<td width=&quot;430&quot; height=&quot;8&quot; rowspan=&quot;2&quot;>
<textarea rows=&quot;5&quot; name=&quot;enterDesc&quot; cols=&quot;40&quot; style=&quot;float: left&quot;></textarea></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;4&quot; colspan=&quot;2&quot;> </td>
<td width=&quot;43&quot; height=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;>
<p align=&quot;left&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Completion
Date:</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot; style=&quot;float: left; position: relative&quot;>

<!--solution for the following calendar form found at
<form name=FrontPage_Form3 style=&quot;float: left&quot; onsubmit=&quot;return FrontPage_Form3_Validator(this)&quot; language=&quot;JavaScript&quot;>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><input type=text name=&quot;datebox&quot; size=15 value=&quot;&quot;>
<a href=&quot;javascript:show_calendar('calform.datebox');&quot; onmouseover=&quot;window.status='Date Picker';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;>
<img src=&quot;show-calendar.gif&quot; width=24 height=22 border=0></a>
</form>

</td>
</tr>
<tr>
<td width=&quot;163&quot; height=&quot;4&quot; colspan=&quot;3&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Additional
Comments:</font></b></td>
<td width=&quot;430&quot; height=&quot;8&quot; rowspan=&quot;2&quot;>
<textarea rows=&quot;3&quot; name=&quot;enterComment&quot; cols=&quot;40&quot;></textarea></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;4&quot; colspan=&quot;2&quot;><b><font face=&quot;Arial Unicode MS&quot;> </font></b></td>
<td width=&quot;43&quot; height=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;593&quot; height=&quot;16&quot; colspan=&quot;4&quot;>
<p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;>    
<input type=&quot;button&quot; value=&quot;Cancel&quot; name=&quot;B2&quot; onClick=&quot;location.href='../change/home.htm'&quot;></td>
</tr>
</table>
</center>
</div>

</body>

</html>
 
I have two sets of code that will spit out the email address of the currently logged in user:

1) Requires Integrated Windows Authentication only
- Must be enabled on client (IE advanced properties)
- A username and password of an AD account that has the rights to search the AD needs to be hardcoded

Code:
<%@ Language=VBScript %>
<%
Option Explicit
Dim strUsername,con,rs,Com,objADsPath,objDomain
%>
<html>
<head>
</head>
<body>
<%
strUsername = Request.ServerVariables(&quot;auth_user&quot;)
strUserName = Right(strUserName, Len(strUserName) - InStrRev(strUserName, &quot;\&quot;))
Set objDomain = GetObject (&quot;GC://rootDSE&quot;)
objADsPath = objDomain.Get(&quot;defaultNamingContext&quot;)
Set objDomain = Nothing
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.provider =&quot;ADsDSOObject&quot;
con.Properties(&quot;User ID&quot;) = &quot;BURLINGTON\adsearch&quot;
con.Properties(&quot;Password&quot;) = &quot;adsearch&quot;
con.open &quot;Active Directory Provider&quot;
Set Com = CreateObject(&quot;ADODB.Command&quot;)
Set Com.ActiveConnection = con
Com.CommandText =&quot;select mail FROM 'GC://&quot;+objADsPath+&quot;' where sAMAccountname='&quot;+strUsername+&quot;'&quot;
Set rs = Com.Execute
response.write rs(&quot;mail&quot;)
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>
</body>
</html>

2) Requires Basic Authentication
- Prompts for username and password]
- Domain name needs to hardcoded in line &quot;con.Properties(&quot;User ID&quot;) =

Code:
<%@ Language=VBScript %>
<%
Option Explicit
Dim strUsername,strUsernamea,strpassword,con,rs,Com,objADsPath,objDomain
%>
<html>
<head>
</head>
<body>
<%
strUsername = Request.ServerVariables(&quot;auth_user&quot;)
strpassword = Request.ServerVariables(&quot;AUTH_PASSWORD&quot;)
strUserNamea = Right(strUserName, Len(strUserName) - InStrRev(strUserName, &quot;\&quot;))
Set objDomain = GetObject (&quot;GC://rootDSE&quot;)
objADsPath = objDomain.Get(&quot;defaultNamingContext&quot;)
Set objDomain = Nothing
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.provider =&quot;ADsDSOObject&quot;
con.Properties(&quot;User ID&quot;) = &quot;BURLINGTON\&quot;+strUsername
con.Properties(&quot;Password&quot;) = strpassword
con.open &quot;Active Directory Provider&quot;
Set Com = CreateObject(&quot;ADODB.Command&quot;)
Set Com.ActiveConnection = con
Com.CommandText =&quot;select mail FROM 'GC://&quot;+objADsPath+&quot;' where sAMAccountname='&quot;+strUsernamea+&quot;'&quot;
Set rs = Com.Execute
response.write rs(&quot;mail&quot;)
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>
</body>
</html>
 
Wow. I got it working! For reference, here's how it's working for me:

1. Code is running on an ASP in a folder with 'anonymous access' turned off in IIS, as described above to allow the 'display username' javascript to work. (As a note, I have it working without requiring 'basic authentication' and also without checking the 'integrated windows authentication' box in IE - the latter of these is not an option for us as nearly all user's desktops are locked down and cannot be changed).

2. I used the code from the second example above, and removed the following three lines of code:

strpassword = Request.ServerVariables(&quot;AUTH_PASSWORD&quot;)
con.Properties(&quot;User ID&quot;) = &quot;BURLINGTON\&quot;+strUsername
con.Properties(&quot;Password&quot;) = strpassword

I was able to paste in the bits about 'VBScript' and have this successfully run along with the existing javascript. May not be groundbreaking stuff, but I'm impressed at least.

Since the ASP in question is already successfully obtaining the username of the logged-on user, I guessed it should be able to query AD without extra authentication. These may not be related, but it works.

zcolton - Thank you *so much* for your direction on this. Great to see the code in action. Piece by piece I'll pick this up. :)

Cheers,
Chris
 
Post what you ended up with. I'ld like to see the changes you made.
 
I'm pleased that this was possible to implement without hardcoding a LDAP server or any company information.. I'm reviewing the code to figure out how this works. :)

Here's my code. The section in question is bold:

<%@ Language=VBScript %>
<%
Option Explicit
Dim strUsername,strUsernamea,strpassword,con,rs,Com,objADsPath,objDomain
%>

<html>

<head>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;en-us&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 5.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<title>Add Change</title>

<script language=&quot;JavaScript&quot; src=&quot;../scripts/calendar.js&quot;></script>

</head>

<body topmargin=&quot;0&quot; leftmargin=&quot;0&quot;>

<table border=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; height=&quot;4%&quot; id=&quot;AutoNumber3&quot; bgcolor=&quot;#000080&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot;>
<tr>
<td width=&quot;100%&quot; height=&quot;25&quot;>
<p align=&quot;center&quot;><font face=&quot;Arial Unicode MS&quot; size=&quot;5&quot; color=&quot;#FFFFFF&quot;>
Change Management</font></td>
</tr>
</table>
<div align=&quot;center&quot;>
<center>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;593&quot; height=&quot;90%&quot; id=&quot;AutoNumber5&quot;>
<tr>
<td width=&quot;593&quot; height=&quot;9&quot; colspan=&quot;4&quot;>
<p align=&quot;center&quot;>
<font face=&quot;Arial Unicode MS&quot; size=&quot;4&quot;>Enter New Change</font></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;><b>
Request Number:</b></font></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<font size=&quot;1&quot; face=&quot;Arial Unicode MS&quot;>(chosen from db, displayed automatically)</font></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Requestor:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<span style=&quot;vertical-align: middle&quot;><font face=&quot;Arial Unicode MS&quot; size=3>
<!-- solution from -->
<!-- displays: DOMAIN\usernam e-->
<!-- <%Response.Write(Request.ServerVariables(&quot;auth_user&quot;))%> -->
<!-- To display only the username... -->
<%
Dim strNTUser, iPos
strNTUser = RTrim(Request.ServerVariables(&quot;LOGON_USER&quot;))
iPos = Len(strNTUser) - InStr(1, strNTUser,&quot;\&quot;,1)
strNTUser = Right(strNTUser, iPos)
Response.Write(strNTUSer)
%>

</font></span>
</td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
E-mail:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<font size=&quot;3&quot; face=&quot;Arial Unicode MS&quot;>

<%
strUsername = Request.ServerVariables(&quot;auth_user&quot;)
strUserNamea = Right(strUserName, Len(strUserName) - InStrRev(strUserName, &quot;\&quot;))
Set objDomain = GetObject (&quot;GC://rootDSE&quot;)
objADsPath = objDomain.Get(&quot;defaultNamingContext&quot;)
Set objDomain = Nothing
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.provider =&quot;ADsDSOObject&quot;
con.open &quot;Active Directory Provider&quot;
Set Com = CreateObject(&quot;ADODB.Command&quot;)
Set Com.ActiveConnection = con
Com.CommandText =&quot;select mail FROM 'GC://&quot;+objADsPath+&quot;' where sAMAccountname='&quot;+strUsernamea+&quot;'&quot;
Set rs = Com.Execute
response.write rs(&quot;mail&quot;)
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
%>

</font>
</td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;9&quot; align=&quot;left&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Status:</font></b></td>
<td width=&quot;473&quot; height=&quot;9&quot; colspan=&quot;3&quot;>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><input type=&quot;text&quot; name=&quot;enterStatus&quot; size=&quot;20&quot; style=&quot;float: left&quot;></td>
</tr>
<tr>
<td width=&quot;593&quot; height=&quot;9&quot; colspan=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Server Name:</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot;>
<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot; onSubmit=&quot;&quot;>
<!--webbot bot=&quot;SaveResults&quot; u-file=&quot;../_private/form_results.csv&quot; s-format=&quot;TEXT/CSV&quot; s-label-fields=&quot;TRUE&quot; startspan --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;0&quot;><!--webbot bot=&quot;SaveResults&quot; endspan i-checksum=&quot;43374&quot; --><p>
<input type=&quot;text&quot; name=&quot;enterServer&quot; size=&quot;20&quot; style=&quot;float: left&quot;></p>
</form>
</td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Production?
(Y/N):</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot;>
<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot; onSubmit=&quot;return FrontPage_Form2_Validator(this)&quot; language=&quot;JavaScript&quot; name=&quot;FrontPage_Form2&quot;>
<!--webbot bot=&quot;SaveResults&quot; u-file=&quot;../_private/form_results.csv&quot; s-format=&quot;TEXT/CSV&quot; s-label-fields=&quot;TRUE&quot; startspan --><input TYPE=&quot;hidden&quot; NAME=&quot;VTI-GROUP&quot; VALUE=&quot;1&quot;><!--webbot bot=&quot;SaveResults&quot; endspan i-checksum=&quot;43406&quot; --><p>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><select size=&quot;1&quot; name=&quot;D1&quot; style=&quot;float: left&quot;>
<option>Yes</option>
<option>No</option>
</select></p>
</form>
</td>
</tr>
<tr>
<td width=&quot;163&quot; height=&quot;4&quot; colspan=&quot;3&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>
Description Of Change:</font></b></td>
<td width=&quot;430&quot; height=&quot;8&quot; rowspan=&quot;2&quot;>
<textarea rows=&quot;5&quot; name=&quot;enterDesc&quot; cols=&quot;40&quot; style=&quot;float: left&quot;></textarea></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;4&quot; colspan=&quot;2&quot;> </td>
<td width=&quot;43&quot; height=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;8&quot;>
<p align=&quot;left&quot;><b><font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Completion
Date:</font></b></td>
<td width=&quot;473&quot; height=&quot;8&quot; colspan=&quot;3&quot; style=&quot;float: left; position: relative&quot;>

<!--solution for the following calendar form found at
<form name=FrontPage_Form3 style=&quot;float: left&quot; onsubmit=&quot;return FrontPage_Form3_Validator(this)&quot; language=&quot;JavaScript&quot;>
<!--webbot bot=&quot;Validation&quot; b-value-required=&quot;TRUE&quot; --><input type=text name=&quot;datebox&quot; size=15 value=&quot;&quot;>
<a href=&quot;javascript:show_calendar('calform.datebox');&quot; onmouseover=&quot;window.status='Date Picker';return true;&quot; onmouseout=&quot;window.status='';return true;&quot;>
<img src=&quot;show-calendar.gif&quot; width=24 height=22 border=0></a>
</form>

</td>
</tr>
<tr>
<td width=&quot;163&quot; height=&quot;4&quot; colspan=&quot;3&quot;><b>
<font face=&quot;Arial Unicode MS&quot; size=&quot;2&quot;>Additional
Comments:</font></b></td>
<td width=&quot;430&quot; height=&quot;8&quot; rowspan=&quot;2&quot;>
<textarea rows=&quot;3&quot; name=&quot;enterComment&quot; cols=&quot;40&quot;></textarea></td>
</tr>
<tr>
<td width=&quot;120&quot; height=&quot;4&quot; colspan=&quot;2&quot;><b><font face=&quot;Arial Unicode MS&quot;> </font></b></td>
<td width=&quot;43&quot; height=&quot;4&quot;></td>
</tr>
<tr>
<td width=&quot;593&quot; height=&quot;16&quot; colspan=&quot;4&quot;>
<p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;>    
<input type=&quot;button&quot; value=&quot;Cancel&quot; name=&quot;B2&quot; onClick=&quot;location.href='../change/home.htm'&quot;></td>
</tr>
</table>
</center>
</div>

</body>

</html>

Thanks once again for the help!
 
Does anyone know what would prevent the 'department' from AD from displaying? Any time I reference the 'department' in the select clause, I get an 'unspecified error' returned from the asp page. I can reference it in the where clause with no error. So:

select name from 'GC://&quot;+objADsPath+&quot;' WHERE department ='Info*'&quot;

works with no errors whereas

select department from 'GC://&quot;+objADsPath+&quot;' WHERE department ='Info*'&quot;

returns the 'unspecified error'.

What could cause this? Are there 'view' rights set up within AD that would prevent displaying them?

Seems very unusual that it works in the 'where' but not in the 'select'.

Thanks
 
You may have to take into account what happens when the value is NULL. I remember adding code for this, though I don't remember if it was for department or another object.
 
I thought that too initially. But in my 'where' clause in the example, you can see that I'm specifying the department='Info*' so any record returned must have a deparment like 'Info*'. It can't have a NULL value and still be returned from the query. The 'where' clause works correctly in referencing the 'department'. My query as written earlier returns 8 records from AD each associated with the Information Systems department. If I remove that part of the 'where' clause, all records are returned from AD. So the 'where department=' works, but the 'select department' does not.

Any other ideas on what might cause it? It sure has me stumped!

Thanks for the reply!


 
Well, I'm no SQL guru...

but if a select works anything like a loop, you may not be able to do a check of:

Info* = NULL
Info* <> NULL
etc...

The reason I think this is we know, well almost know, that everyone probably has a name populated. Thus, this works fine. But we may not have gotten around to populating dept for everyone.

Don't know for sure though, sorry. You're welcome to have a copy of my endeavor if you wish, it's somewhat different and may/may not help. Just shoot me an email.
 
The thing is, I can select other NULL values such as 'telephonenumber' and I get no errors. As soon as I reference the 'department'in the 'select', even when I know it isn't NULL, I immediately get the error. I'm not even trying to write the recordset to html at this point. I'm just executing the query and still get the error. So it isn't related to displaying the results, it is related to the query itself. It almost appears that I don't have rights to 'select' the department. That is the only thing I can think of that would cause this.

Does AD allow you to limit/restrict viewing rights of fields? Can fields be blocked from running 'select' statements on them?

 
I have the same problem...can't find any info on it and my Network Admin doesn't know. It has nothing to do with the field being empty as I can run a query with &quot;Description&quot; in the select portion and I get no error when there are records with no value for that attribute.

Anyone figure this one out???
 
I keep getting the following error when looking at some of these code:

Provider error '80004005'
Unspecified error
/test.asp, line 45

Line 45 is:
Set rs = Com.Execute

Is something not installed on my server correctly?

Digatle
 
From what I've researched you have to enable &quot;Trusted for Delegation&quot; on the web server account and your domain must be native. Our domain is not native...so we'll see.
 
What do I need to do then to be able to use these scripts?

Digatle
 
First thing is make sure you are on a native domain. If you have any W98 machines on the domain then more than likely you are not.
Enabling &quot;Trusted for Delegation&quot; is done under the Active Directory computer account for the web server. I can't remember what tab it's under.
If you are not the Net Admin pass this on to him and he should know.
I'm not 100% that this will allow your scripts to run but from what I've researched this is the starting point.
 
We are still struggling with this issue pReverend. Any other suggestions?

Digatle
 
To all who are having problems:

Most issues are do to security. A few things to keep in mind. The account used to run the scripts needs to have the ability to search/read active directory. I configured a domain account that has those rights and configured that account for the anonymous account on the directory that contains the phonebook pages. That account also needs to have read rights on that directory and the files contain within. There other ways if you cannot make or do not want to make these changes in the server, but it would require you to hard code a username and password in the asp pages.
 
zcolton,
I assume you can assign groups to read from this as well...that's what we did but no success. This is on an intranet where I get the client's username from iis so I cannot use anon logon. I compare the username with the sAMAccountName and collect info about the user that way. This prevents them from having to logon (again) which irritates most of our users under the current process.
The only time it worked reliably was when the web server was promoted to dc.
In your experience is it true you have to be on a native domain for these queries to work through trusted delegation?

 
I am on a native domain, but I think I had this up and running before I switched to a native domain. My IIS server isn't a DC. It is a domain member. The lasted phonebook.zip I put up queries the global catalog (GC://) instead of LDAP. GC searches are faster than LDAP. There are this you can do to test connection. First start with the basics:

<%@ Language=VBScript %>
<%
Option Explicit
Dim objADsPath,objDomain
%>
<html>
<head>
</head>
<body>
<%
Set objDomain = GetObject (&quot;GC://RootDSE&quot;)
objADsPath = objDomain.Get(&quot;defaultNamingContext&quot;)
Set objDomain = Nothing
Response.Write objADsPath & &quot;<BR>&quot;
%>
</body>
</html>

This should spit out your domain info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top