LoganDecker84
MIS
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
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