I have been reading the following thread:
thread774-356151
Wow zcolton you are the most helpful person I have ever encounted in any forum. I have been strugling to get a list of users and phone numbers. The following code works to get 'a users details' however I would like to get the full list.
Why can I not change the following line:
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
To:
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"'"
To acieve my objective? Thank you in advance...this one had me very stuck
<%
fsCompletted = Request.QueryString("f")
If fsCompletted = 1 Then
ResultHTML = ProcessForm
else
ResultHTML = "<br>"
End If
Function ProcessForm
on error resume next
oUsername=Request.Form("username")
oPassword=Request.Form("password")
strUserName = Right(oUsername, Len(oUsername) - InStrRev(oUsername, "\"))
if InStr(strUserName, "@")>0 then
strUserName = Left(strUserName, InStr(strUserName, "@")-1)
end if
Set objDomain = GetObject("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.Properties("User ID") = oUsername
con.Properties("Password") = oPassword
con.Properties("Encrypt Password") = False
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
if err.number=0 then
HTML = "<p>"+rs("name")+"<br>"+rs("telephonenumber")+"<br>"+rs("mail")+"</p>"
else
HTML = "<p>Not Authenticated</p>"
end if
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
ProcessForm=HTML
End Function
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?f=1" %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ResultHTML%>
<%if request.querystring("f")="" then %>
<form method="post" Action="<%=PostURL%>">
<p>Username : <input type="text" Name="username" value="" Size="25">(yourDomain/username)</p>
<p>Password : <input type="password" Name="password" Size="25"></p>
<input Name=SubmitButton Value="Authenticate User" Type=submit>
</form>
<%end if%>
</BODY>
</HTML>
thread774-356151
Wow zcolton you are the most helpful person I have ever encounted in any forum. I have been strugling to get a list of users and phone numbers. The following code works to get 'a users details' however I would like to get the full list.
Why can I not change the following line:
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
To:
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"'"
To acieve my objective? Thank you in advance...this one had me very stuck
<%
fsCompletted = Request.QueryString("f")
If fsCompletted = 1 Then
ResultHTML = ProcessForm
else
ResultHTML = "<br>"
End If
Function ProcessForm
on error resume next
oUsername=Request.Form("username")
oPassword=Request.Form("password")
strUserName = Right(oUsername, Len(oUsername) - InStrRev(oUsername, "\"))
if InStr(strUserName, "@")>0 then
strUserName = Left(strUserName, InStr(strUserName, "@")-1)
end if
Set objDomain = GetObject("GC://rootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.Properties("User ID") = oUsername
con.Properties("Password") = oPassword
con.Properties("Encrypt Password") = False
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select name,telephonenumber,mail FROM 'GC://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
if err.number=0 then
HTML = "<p>"+rs("name")+"<br>"+rs("telephonenumber")+"<br>"+rs("mail")+"</p>"
else
HTML = "<p>Not Authenticated</p>"
end if
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
ProcessForm=HTML
End Function
PostURL = Request.ServerVariables("SCRIPT_NAME") & "?f=1" %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%=ResultHTML%>
<%if request.querystring("f")="" then %>
<form method="post" Action="<%=PostURL%>">
<p>Username : <input type="text" Name="username" value="" Size="25">(yourDomain/username)</p>
<p>Password : <input type="password" Name="password" Size="25"></p>
<input Name=SubmitButton Value="Authenticate User" Type=submit>
</form>
<%end if%>
</BODY>
</HTML>