ASP <-> LDAP

Discussion in 'ASP General' started by Fabian Baum, Feb 22, 2005.

  1. Fabian Baum

    Fabian Baum Guest

    Hi,

    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"
    Response.End
    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)(givenName=Fabian)(sn=Baum));a
    dsPath,name,ou;subTree"

    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 = objUser.sn
    strEmail = objUser.mail
    strKostenstelle = objUser.description
    strNTUser = objUser.cn
    strAbteilung = objUser.department

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

    rs.MoveNext
    loop
    Set objUser = Nothing

    set con = Nothing
    set ocommand = Nothing
     
    Fabian Baum, Feb 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    533
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Replies:
    1
    Views:
    339
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    254
  4. Ian Macdonald
    Replies:
    0
    Views:
    218
    Ian Macdonald
    Mar 15, 2005
  5. James Hughes
    Replies:
    4
    Views:
    330
    James Hughes
    Dec 13, 2005
Loading...

Share This Page