Re: NEWBIE: Pulling basic AD data

From: KWilliams (anonymous_at_discussions.microsoft.com)
Date: 09/01/04


Date: Wed, 1 Sep 2004 07:56:48 -0700

Hi Matjaz,

After doing some testing, I realized the same thing. I
then found a solution that uses LDAP from an ASP 3.0
book, and it appears to work partially. But when it gets
to Line , it stalls. If I remove the repeat, it runs fine
but doesn't pull up any records. I've also tried limiting
the Record count to under 10, but it still locks up. I've
included the code below. If you see anything that I'm
obviously doing incorrectly, it would be greatly
appreciated to hear your advice. Thanks Matjaz.

KWilliams

LDAP CODE:

<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>ADSI Search Page</title>
</head>
<body>
<h1>ADSI Search Page</h1>
This page uses ADSI to search a directory
<p><strong>Search Request:</strong><br>
<%
On Error Resume Next

Dim strSearchBase
strSearchBase = "LDAP://dc=SERVER,dc=NAME"
Dim strFilter
strFilter = "(objectCategory=USERNAME)"
Dim strAttribs
strAttribs = "sAMAccountName,ADsPath"
Dim strScope
strScope = "subtree"

Response.Write "Search Base: " & strSearchBase & "<br>"
Response.Write "Filter: " & strFilter & "<br>"
Response.Write "Properties Requested: " & strAttribs
& "<br>"
Response.Write "Scope: " & strScope & "<br>"

Dim strCommandText '<<--Line 27
'strCommandText = "<" & strSearchBase & ">;name;" &
strScope
strCommandText = "<" & strSearchBase & ">;name" _
& strFilter & ";" & strAttribs & ";" & strScope
Response.Write "<strong>Command Text: </strong><br>"
Response.Write Server.HTMLEncode(strCommandText) & "<p>"

Dim objConnection
Set objConnection = Server.CreateObject
("ADODB.Connection")
Dim objCommand
Set objCommand = Server.CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = strCommandText

Dim objRecordset
Set objRecordset = objCommand.Execute(strCommandText)

Response.Write "<table border=4><tr>"
If (Not objRecordset.EOF) Then
        For Each objField in objRecordset.Fields
                Response.Write "<td>"
                Response.Write objField.Name
                Response.Write "</td>"
        Next
End If
Response.Write "</tr>"

'While Not objRecordset.EOF AND Count <= 10
        Response.Write "<tr>"
        For Each oField in objRecordset.Fields
                Response.Write "<td>"
                Response.Write objField.Value
                Response.Write "</td>"
        Next
        Response.Write "</tr>"
' objRecordset.MoveNext
'Wend
Response.Write "</tr></table>"
%>
</body>
</html>

>-----Original Message-----
>>From the code I can see, that you are using WinNT
provider. I would suguest
>you to use LDAP provider as it is more powerfull. WinNT
provider is for
>backward compatibility with NT systems and does not
exposes all user
>attributes.
>To get LDAP distinguished name from username use
NameTranslate object
>(http://www.rlmueller.net/NameTranslateFAQ.htm#What%20is%
20NameTranslate)
>
>--
>lp
>
>Matjaz
>http://www.slowug.org



Relevant Pages

  • Re: Need WMI script
    ... WinNT provider reveals the "primary" group, ... I also assume that strGroupName ... Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, ... However, if you use the cscript host, ...
    (microsoft.public.windows.server.scripting)
  • RE: ADODB to ADO.NET conversion
    ... LDAP, ActiveDirectory service. ... if you want to query ... Dim entry As New ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: LDAP and SASL
    ... LDAP SSL handshake if one is available and configured correctly. ... > Dim searcherLdap As New DirectorySearcher ... > Dim obProp As Object ... > ReDim arrFName ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Need to read "Store password in reversible encryption for all users in the domain"
    ... I always avoid the LDAP provider like the plague. ... as well as servers in domains. ... You can use these filters in ADUC. ...
    (microsoft.public.windows.server.scripting)
  • SDK 3.00 .net provider and MS visual studio
    ... Database is Informix Online 9.40 on a Sun Solaris machine, connecting from a windows XP client machine with SDK 3.00.TC3 installed (.net provider). ... using btree; ... Dim IfxDataAdaptorBankTrans As New ...
    (comp.databases.informix)