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

Input multiple users ASP page

Status
Not open for further replies.
Aug 15, 2006
14
US
Hello again.

I have an .aspx home page that allows you to enter multiple users(one on each line) and when you click submit it should query A/D and return the requested attribs. Problem is, it only works when I use a single text box and enter one user, but when I made it into a multiple text box and enter multiple users, it returns no information, just a blank page


Index.aspx
-----------------------------

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
End Sub
</script>

<h2>Display New User Accounts</h2>
<p>
Please choose from one of the search methods below:

<form method="POST" action="extattrib7test.asp">


Enter Username you wish to search for:<br>
<form runat="server">
<input type="radio" name="SearchOption" value="byuser" align=middle ID=r1 tabindex=8>
Search for a Specific UserID:


<asp:TextBox MaxLength="200" TextMode="MultiLine" id="specificuser" Height="100px" Width="400px" runat="server" OnClick="document.getElementById('r1').checked='true'" tabindex=9 />
<asp:Button id = "lbll" type="submit" OnClick="submit" Text="Submit" runat="server" tabindex=9/>

<!--<input type="submit" value="Submit data" tabindex=9>-->
<input type="reset" value="Clear" tabindex=10>

</p>

</form></form>
------------------------------------

vbscript query to A/D - extattrib7test.asp

--------------------------------------

<%@ Language="VBScript" %>
<%
'Option Explicit
%>
<HTML>
<HEAD>
<TITLE>Ext Attrib 7</TITLE>
</HEAD>
<%
Dim oRootDSE, objConnection, oCmd, objRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount

Set specificuser2 = Request.Form("specificuser")
specificuser2 = LCase(specificuser2)

Set objConnection = Server.CreateObject("ADODB.Connection")
Set objCommand = Server.CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("GC://RootDSE")
strDNSDomain = "LDAP://" & objRootDSE.Get("defaultNamingContext")
Set objRootDSE = nothing
strBase = "<LDAP://ou=sites,dc=test,dc=com>"
'strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=person)(objectClass=user))"
strAttributes = "sAMAccountName,extensionattribute6,name"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 1000
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute

If objRecordSet.RecordCount >0 then

Do Until objRecordSet.EOF
For each itm in objRecordSet.Fields

If (objRecordSet.Fields("samAccountName").Value) = specificuser2 Then
Response.Write("<tr><td>" & objRecordSet.Fields("name") & "</td><td>" & objRecordSet.Fields("extensionattribute6") & "</td>")
End If
Next
objRecordSet.MoveNext

loop
end if
Response.Write("</font>")
Response.Write("</table>")

objRecordSet.Close
objConnection.Close

Set objRecordSet = Nothing
Set objConnection = Nothing

%>
</BODY>
</HTML>

------------------------------------

Any help is very much appreciated
 
Well if specificuser2 now contains multiple lines with names...how do you expect to compare it with a single value you retrieve through your query?

Maybe break up the lines, insert them into a dictionary, and then use its Exists method to test and see if it matches what your query has returned.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
As usual I need your assistance on this one. If this was a regular Vbscript, I could import the users from a text file, and do it that way with no problem(thanks to you), but with this ASP page, I have no clue how to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top