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

AD user info pull via asp

Status
Not open for further replies.

militarymedic22

Technical User
Dec 11, 2007
4
US

I am fairly new to asp and scripting but here is my project.
Have a vbs file, converted over to asp. But I've probably been staring at it so long I can't see what might be wrong or how to fix it.
Can somebody please verify or suggest corrections?

Thanks!

I started with disabling nearly everything, and am slowly enabling portions to see what errors out. The point I'm at right now results in the error 'Object doesn't support this property or method: 'ActiveConnection' I have received quite a few other Object doesn't support errors prior to now, but I can't quite figure out what tiny thing I might have changed to make it go away.


Code:
<%@ Language="VBScript" %>

<%

Dim strUserName

Dim adoCommand, adoConnection, strBase, strFilter, strAttributes, rs, com, intUAC

Dim objRootDSE, strRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN

Dim str_a, str_b, str_c, objNet

Dim arrUser, strNTUser
arrUser = Split(Request.ServerVariables("LOGON_USER"), "\")
strNTUser = arrUser(1)

response.write(strNTUser)

'' Setup ADO objects.
set objRootDSE = getObject("LDAP://rootDSE")
strRootDSE = objRootDSE.Get("defaultNamingContext")

response.write(strRootDSE)
'objRootDSE = Nothing

set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open("Active Directory Provider")

adoCommand = CreateObject("ADODB.Command")
adoCommand.ActiveConnection = adoConnection

'adoCommand.CommandText = "SELECT mail,title,department,cn,name,sAMAccountName,displ ayname FROM 'LDAP://" & strRootDSE & "' " _
'& "WHERE sAMaccountName='" & strNTUser & "'"


''rs = adoCommand.Execute
''While Not rs.eof
' ' intUAC = rs.fields("name")
''End While
'adoCommand.CommandText = strQuery
'adoCommand.Properties("Page Size") = 100
'adoCommand.Properties("Timeout") = 30
'adoCommand.Properties("Cache Results") = False



'' Run the query.
'adoRecordset = adoCommand.Execute
'response.write(adoCommand)


'' Enumerate the resulting recordset.
''Do Until adoRecordset.EOF

'' Retrieve values and display.
'strName = adoRecordset.Fields("sAMAccountName").Value
'str_a = adoRecordset.Fields("displayName").Value
'str_b = adoRecordset.Fields("name").Value
'str_c = adoRecordset.Fields("title").Value

'strCN = adoRecordset.Fields("cn").value

'Response.Write("NT Name: " & strName & ", Common Name: " & strCN)
'Response.Write("displayname " & str_a & ", email " & str_b & ", " & str_c)

'' Move to the next record in the recordset.
''adoRecordset.MoveNext()
''Loop



'' Clean up.

'adoRecordset.Close()

'adoConnection.Close()
%>

<head>
<title>Untitled Page</title>
</head>
<body>

<p>Field0: <%=strNTUser%></p>
<p>Field1: <%=str_a%></p>
<p>Field2: <%=str_b%></p>
<p>Field3: <%=str_c%></p>
<p>Field4: <%=strCN%></p>


</body>
</html>
	
Edit/Delete Message
 
>adoCommand = CreateObject("ADODB.Command")
[tt][red]set[/red] adoCommand = CreateObject("ADODB.Command")[/tt]
You may as well specify the host, applicable for any lines before it and after.
[tt][red]set[/red] adoCommand = [blue]server.[/blue]CreateObject("ADODB.Command")[/tt]
 
Further note:
I have not read any other lines with the intention of debugging. But, just by proximity, the following line is not correct neither.
>adoCommand.ActiveConnection = adoConnection
[tt][red]set[/red] adoCommand.ActiveConnection = adoConnection[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top