Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP <-> LDAP

Thread Tools


Fabian Baum
Posts: n/a

i have a problem in the following source code, i cant read the department
from the AD ;(
where is my mistake?

Dim strBrowser 'Brausertyp

If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Unauthorized"
End If

Dim strUserADsPath 'ADSI user ads path
Dim objUser 'ADSI user object
Dim strADSPath 'ADS path

Dim strUserID 'User Name
Dim strUserDomain 'User Domain
Dim intSlash 'Hilfsvariable zum trennen von Domain und User
Dim strSpath 'Suchpfad im AD

Dim rs 'ADODB Recordset
Dim con 'Handle zur ADODB Verbindung
Dim ocommand 'ADODB Query Command

Dim strVorname
Dim strNachname
Dim strEmail
Dim strKostenstelle

strUserAdsPath = Request.ServerVariables("LOGON_USER")

intSlash = instr(1,strUserAdsPath,"\")

strUserDomain = mid(strUserAdsPath,1,intSlash -1 )
strUserID = mid(strUserAdsPath,intSlash + 1 ,(len(strUserAdsPath)))

strSpath = "LDAP://dc=" & strUserDomain & ",dc=domain,dc=com"

'ADO Connection object
Set con = CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject"
con.Open "Active Directory Provider"

'ADO Command object
Set ocommand = CreateObject("ADODB.Command")
ocommand.ActiveConnection = con
ocommand.CommandText = "<" & strSpath &
">;(&(objectCategory=person)(objectClass=user)(giv enName=Fabian)(sn=Baum));a

Set rs = ocommand.Execute

Do While Not(rs.EOF)

' Connecten zum User im AD
strUserADsPath = rs.Fields(0).value

set objUser = GetObject(strUserADsPath)

strVorname = objUser.givenName
strNachname =
strEmail = objUser.mail
strKostenstelle = objUser.description
strNTUser =
strAbteilung = objUser.department

Response.Write "<br>SN: " & objUser.department

Set objUser = Nothing

set con = Nothing
set ocommand = Nothing

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
python-ldap/win32 or python/ldap/win32 rcmn Python 1 11-06-2006 11:47 PM
Need to wrtie LDAP class to *answer* LDAP queries. Java 1 02-21-2006 09:59 PM
ruby-ldap: uninitialized constant LDAP::LDAP_CONTROL_PAGEDRESULTS James Hughes Ruby 4 12-13-2005 11:46 PM
[ANN] Ruby/LDAP 0.9.1: LDAP API (RFC1823) library. Ian Macdonald Ruby 0 03-15-2005 11:23 PM
using LDAP Controls in ruby-ldap Jason Wold Ruby 5 11-07-2004 03:35 AM