locked
cannot able retrieve data from LDAP from ASP RRS feed

  • Question

  • User84749528 posted
    Dear All,
     i am trying to retrive data from ad but its not working, can any one help me.
    <html>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>testsearch</title>
    <script language="JavaScript"></script>
    </head>
    <body>
    <%
    on error resume next
         strLogonID = Request.Servervariables("LOGON_USER")
    Response.Write "<script type='text/javascript'>alert('" & strLogonID & "');</script>"
    strLogonID = LCase(right(strLogonID, InStr(strLogonID, "t") + 7))
        
         id = LCase(strLogonID)
        Set User = GetObject("WinNT://abanet/" & id & "")
         Fullname = User.Fullname
    '###### Pathway to use to Active Directory ######   &&&&& from here onwards i am not able to retrive data &&&&&
    set usr = GetObject("LDAP://cn=Fullname,ou=Users,OU=HO IT,dc=abanet,dc=local")
    Response.Write "<script type='text/javascript'>alert('" & usr & "');</script>"
     
    '###### Flush any cache held ######
    usr.GetInfo
    Response.Write "<script type='text/javascript'>alert('" & usr.get("department") & "');</script>"
    '###### Active Directory variables ######
    strName = usr.get("NAME") '###### Users Christian Name ######
    strSurname = usr.get("sn") '###### Users Surname ######
    strInitials = usr.get("initials") '###### Users Initials ######
    displayName = usr.get("displayName") '###### Full Display Name ######
    strAddress = usr.get("StreetAddress") '###### Address Information ######
    strRoom = usr.get("PhysicalDeliveryOfficeName") '###### Room/Area Information ######
    secretary = usr.get("secretary") '###### Secrectary/Assistant ######
    strTitle = usr.get("title") '###### Job Title ######
    strTelephone = usr.get("telephoneNumber") '###### Official Intneral Telephone Number ######
    strFax = usr.get("facsimileTelephoneNumber") '###### Fax Number ######
    mobile = usr.get("mobile") '###### Mobile Number ######
    telephoneAssistant = usr.get("telephoneAssistant") '###### Telephone Assistant ######
    strDepartment = usr.get("department") '###### Department ######
    strCC = usr.get("ExtensionAttribute1") '###### COST Centre ######
    strBuilding = usr.get("ExtensionAttribute2") '###### Building ######
    strDivision = usr.get("ExtensionAttribute3") '###### Division ######
    strBranch = usr.get("ExtensionAttribute4") '###### Branch ######
    ExtensionAttribute5 = usr.get("ExtensionAttribute5") '###### PC Item Number ######
    ExtensionAttribute6 = usr.get("ExtensionAttribute6") '###### External Telephone Number ######
    strGroup = usr.get("ExtensionAttribute7") '###### Group ######
    othertelephone = usr.get("othertelephone") '###### GTN Telephone Number ######
    samaccountname = usr.get("samaccountname") '###### User ID ######
    adspath = usr.get("adspath") '###### Pathway to AD? ######
    strFullName = usr.get("cn") '###### Full Display Name ######
    strMail = usr.get("mail") '###### E-Mail Address ######
    strManager = usr.get("manager")                                   '###### Reporting Officer ######
    '###### End Active Directory variables ######
    set usr = nothing
    Response.Write "<script type='text/javascript'>alert('" & strName & "');</script>"
    Response.Write     "Firstname = " & strName  & "<br />"
    Response.Write     "Surname = " & strSurname & "<br />"
    Response.Write     "initials = " & strInitials & "<br />"
    Response.Write     "displayName = " & displayName & "<br />"
    Response.Write     "StreetAddress = " & strAddress & "<br />"
    Response.Write     "PhysicalDeliveryOfficeName = " & strRoom & "<br />"
    Response.Write     "secretary = " & secretary & "<br />"
    Response.Write     "title = " & strTitle & "<br />"
    Response.Write     "telephoneNumber = " & strTelephone & "<br />"
    Response.Write     "facsimileTelephoneNumber = " & strFax & "<br />"
    Response.Write     "mobile = " & mobile & "<br />"
    Response.Write     "telephoneAssistant = " & telephoneAssistant & "<br />"
    Response.Write     "department = " & strDepartment & "<br />"
    Response.Write     "ExtensionAttribute1 = " & strCC & "<br />"
    Response.Write     "ExtensionAttribute2 = " & strBuilding & "<br />"
    Response.Write     "ExtensionAttribute3 = " & strDivision & "<br />"
    Response.Write     "ExtensionAttribute4 = " & strBranch & "<br />"
    Response.Write     "ExtensionAttribute5 = " & ExtensionAttribute5 & "<br />"
    Response.Write     "ExtensionAttribute6 = " & ExtensionAttribute6 & "<br />"
    Response.Write     "ExtensionAttribute7 = " & strGroup & "<br />"
    Response.Write     "othertelephone = " & othertelephone & "<br />"
    Response.Write     "samaccountname = " & samaccountname & "<br />"
    Response.Write     "adspath = " & adspath & "<br />"
    Response.Write     "FullName = " & strFullName & "<br />"
    Response.Write     "e-mail = " & strMail & "<br />"
    Response.Write     "strManager = " & strManager & "<br />"
    If Err.Number <> 0 Then
          GetInfo = False
          Response.Write(Err.Number & ": " & Err.Description) 'always get "The Active Directory datatype cannot be converted to/from a native DS datatype" 
          Err.Clear
      Else
          GetInfo = True
      End If
    %>
    </body>
    </html>

     

    Dear All,

     i am trying to retrive data from ad but its not working, can any one help me.

    if cannot how to do in ASP.net in the similar way

    <html>

    <head>

    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">

    <meta name="ProgId" content="FrontPage.Editor.Document">

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

    <title>testsearch</title>

    <script language="JavaScript"></script>

    </head>

    <body>

    <%

    on error resume next

         strLogonID = Request.Servervariables("LOGON_USER")

    Response.Write "<script type='text/javascript'>alert('" & strLogonID & "');</script>"

    strLogonID = LCase(right(strLogonID, InStr(strLogonID, "t") + 7))

     

         id = LCase(strLogonID)

        Set User = GetObject("WinNT://abanet/" & id & "")

         Fullname = User.Fullname

    '###### Pathway to use to Active Directory ######   &&&&& from here onwards i am not able to retrive data &&&&&

    set usr = GetObject("LDAP://cn=Fullname,ou=Users,OU=HO IT,dc=abanet,dc=local")

    Response.Write "<script type='text/javascript'>alert('" & usr & "');</script>"

    '###### Flush any cache held ######

    usr.GetInfo

    Response.Write "<script type='text/javascript'>alert('" & usr.get("department") & "');</script>"

    '###### Active Directory variables ######

    strName = usr.get("NAME") '###### Users Christian Name ######

    strSurname = usr.get("sn") '###### Users Surname ######

    strInitials = usr.get("initials") '###### Users Initials ######

    displayName = usr.get("displayName") '###### Full Display Name ######

    strAddress = usr.get("StreetAddress") '###### Address Information ######

    strRoom = usr.get("PhysicalDeliveryOfficeName") '###### Room/Area Information ######

    secretary = usr.get("secretary") '###### Secrectary/Assistant ######

    strTitle = usr.get("title") '###### Job Title ######

    strTelephone = usr.get("telephoneNumber") '###### Official Intneral Telephone Number ######

    strFax = usr.get("facsimileTelephoneNumber") '###### Fax Number ######

    mobile = usr.get("mobile") '###### Mobile Number ######

    telephoneAssistant = usr.get("telephoneAssistant") '###### Telephone Assistant ######

    strDepartment = usr.get("department") '###### Department ######

    strCC = usr.get("ExtensionAttribute1") '###### COST Centre ######

    strBuilding = usr.get("ExtensionAttribute2") '###### Building ######

    strDivision = usr.get("ExtensionAttribute3") '###### Division ######

    strBranch = usr.get("ExtensionAttribute4") '###### Branch ######

    ExtensionAttribute5 = usr.get("ExtensionAttribute5") '###### PC Item Number ######

    ExtensionAttribute6 = usr.get("ExtensionAttribute6") '###### External Telephone Number ######

    strGroup = usr.get("ExtensionAttribute7") '###### Group ######

    othertelephone = usr.get("othertelephone") '###### GTN Telephone Number ######

    samaccountname = usr.get("samaccountname") '###### User ID ######

    adspath = usr.get("adspath") '###### Pathway to AD? ######

    strFullName = usr.get("cn") '###### Full Display Name ######

    strMail = usr.get("mail") '###### E-Mail Address ######

    strManager = usr.get("manager")                                   '###### Reporting Officer ######

    '###### End Active Directory variables ######

    set usr = nothing

    Response.Write "<script type='text/javascript'>alert('" & strName & "');</script>"

    Response.Write     "Firstname = " & strName  & "<br />"

    Response.Write     "Surname = " & strSurname & "<br />"

    Response.Write     "initials = " & strInitials & "<br />"

    Response.Write     "displayName = " & displayName & "<br />"

    Response.Write     "StreetAddress = " & strAddress & "<br />"

    Response.Write     "PhysicalDeliveryOfficeName = " & strRoom & "<br />"

    Response.Write     "secretary = " & secretary & "<br />"

    Response.Write     "title = " & strTitle & "<br />"

    Response.Write     "telephoneNumber = " & strTelephone & "<br />"

    Response.Write     "facsimileTelephoneNumber = " & strFax & "<br />"

    Response.Write     "mobile = " & mobile & "<br />"

    Response.Write     "telephoneAssistant = " & telephoneAssistant & "<br />"

    Response.Write     "department = " & strDepartment & "<br />"

    Response.Write     "ExtensionAttribute1 = " & strCC & "<br />"

    Response.Write     "ExtensionAttribute2 = " & strBuilding & "<br />"

    Response.Write     "ExtensionAttribute3 = " & strDivision & "<br />"

    Response.Write     "ExtensionAttribute4 = " & strBranch & "<br />"

    Response.Write     "ExtensionAttribute5 = " & ExtensionAttribute5 & "<br />"

    Response.Write     "ExtensionAttribute6 = " & ExtensionAttribute6 & "<br />"

    Response.Write     "ExtensionAttribute7 = " & strGroup & "<br />"

    Response.Write     "othertelephone = " & othertelephone & "<br />"

    Response.Write     "samaccountname = " & samaccountname & "<br />"

    Response.Write     "adspath = " & adspath & "<br />"

    Response.Write     "FullName = " & strFullName & "<br />"

    Response.Write     "e-mail = " & strMail & "<br />"

    Response.Write     "strManager = " & strManager & "<br />"

     

    If Err.Number <> 0 Then

          GetInfo = False

          Response.Write(Err.Number & ": " & Err.Description) 'always get "The Active Directory datatype cannot be converted to/from a native DS datatype" 

          Err.Clear

      Else

          GetInfo = True

      End If

    %>

    </body>

    </html>

     

    Wednesday, May 26, 2010 2:39 PM

All replies

  • User-456111751 posted

    Please refer: http://www.codeproject.com/KB/system/everythingInAD.aspx

     

    Friday, May 28, 2010 7:00 AM
  • User-456111751 posted

    Also refer this post for code http://forums.asp.net/t/1559793.aspx 

    Friday, May 28, 2010 7:01 AM
  • User1508394307 posted

    Dear All,
     i am trying to retrive data from ad but its not working, can any one help me.
    <html>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>testsearch</title>
    <script language="JavaScript"></script>
    </head>
    <body>
    <%
    on error resume next
         strLogonID = Request.Servervariables("LOGON_USER")
    Response.Write "<script type='text/javascript'>alert('" & strLogonID & "');</script>"
    strLogonID = LCase(right(strLogonID, InStr(strLogonID, "t") + 7))
        
         id = LCase(strLogonID)
        Set User = GetObject("WinNT://abanet/" & id & "")
         Fullname = User.Fullname
    '###### Pathway to use to Active Directory ######   &&&&& from here onwards i am not able to retrive data &&&&&
    set usr = GetObject("LDAP://cn=Fullname,ou=Users,OU=HO IT,dc=abanet,dc=local")
    Response.Write "<script type='text/javascript'>alert('" & usr & "');</script>"
     
    '###### Flush any cache held ######
    usr.GetInfo
    Response.Write "<script type='text/javascript'>alert('" & usr.get("department") & "');</script>"
    '###### Active Directory variables ######
    strName = usr.get("NAME") '###### Users Christian Name ######
    strSurname = usr.get("sn") '###### Users Surname ######
    strInitials = usr.get("initials") '###### Users Initials ######
    displayName = usr.get("displayName") '###### Full Display Name ######
    strAddress = usr.get("StreetAddress") '###### Address Information ######
    strRoom = usr.get("PhysicalDeliveryOfficeName") '###### Room/Area Information ######
    secretary = usr.get("secretary") '###### Secrectary/Assistant ######
    strTitle = usr.get("title") '###### Job Title ######
    strTelephone = usr.get("telephoneNumber") '###### Official Intneral Telephone Number ######
    strFax = usr.get("facsimileTelephoneNumber") '###### Fax Number ######
    mobile = usr.get("mobile") '###### Mobile Number ######
    telephoneAssistant = usr.get("telephoneAssistant") '###### Telephone Assistant ######
    strDepartment = usr.get("department") '###### Department ######
    strCC = usr.get("ExtensionAttribute1") '###### COST Centre ######
    strBuilding = usr.get("ExtensionAttribute2") '###### Building ######
    strDivision = usr.get("ExtensionAttribute3") '###### Division ######
    strBranch = usr.get("ExtensionAttribute4") '###### Branch ######
    ExtensionAttribute5 = usr.get("ExtensionAttribute5") '###### PC Item Number ######
    ExtensionAttribute6 = usr.get("ExtensionAttribute6") '###### External Telephone Number ######
    strGroup = usr.get("ExtensionAttribute7") '###### Group ######
    othertelephone = usr.get("othertelephone") '###### GTN Telephone Number ######
    samaccountname = usr.get("samaccountname") '###### User ID ######
    adspath = usr.get("adspath") '###### Pathway to AD? ######
    strFullName = usr.get("cn") '###### Full Display Name ######
    strMail = usr.get("mail") '###### E-Mail Address ######
    strManager = usr.get("manager")                                   '###### Reporting Officer ######
    '###### End Active Directory variables ######
    set usr = nothing
    Response.Write "<script type='text/javascript'>alert('" & strName & "');</script>"
    Response.Write     "Firstname = " & strName  & "<br />"
    Response.Write     "Surname = " & strSurname & "<br />"
    Response.Write     "initials = " & strInitials & "<br />"
    Response.Write     "displayName = " & displayName & "<br />"
    Response.Write     "StreetAddress = " & strAddress & "<br />"
    Response.Write     "PhysicalDeliveryOfficeName = " & strRoom & "<br />"
    Response.Write     "secretary = " & secretary & "<br />"
    Response.Write     "title = " & strTitle & "<br />"
    Response.Write     "telephoneNumber = " & strTelephone & "<br />"
    Response.Write     "facsimileTelephoneNumber = " & strFax & "<br />"
    Response.Write     "mobile = " & mobile & "<br />"
    Response.Write     "telephoneAssistant = " & telephoneAssistant & "<br />"
    Response.Write     "department = " & strDepartment & "<br />"
    Response.Write     "ExtensionAttribute1 = " & strCC & "<br />"
    Response.Write     "ExtensionAttribute2 = " & strBuilding & "<br />"
    Response.Write     "ExtensionAttribute3 = " & strDivision & "<br />"
    Response.Write     "ExtensionAttribute4 = " & strBranch & "<br />"
    Response.Write     "ExtensionAttribute5 = " & ExtensionAttribute5 & "<br />"
    Response.Write     "ExtensionAttribute6 = " & ExtensionAttribute6 & "<br />"
    Response.Write     "ExtensionAttribute7 = " & strGroup & "<br />"
    Response.Write     "othertelephone = " & othertelephone & "<br />"
    Response.Write     "samaccountname = " & samaccountname & "<br />"
    Response.Write     "adspath = " & adspath & "<br />"
    Response.Write     "FullName = " & strFullName & "<br />"
    Response.Write     "e-mail = " & strMail & "<br />"
    Response.Write     "strManager = " & strManager & "<br />"
    If Err.Number <> 0 Then
          GetInfo = False
          Response.Write(Err.Number & ": " & Err.Description) 'always get "The Active Directory datatype cannot be converted to/from a native DS datatype" 
          Err.Clear
      Else
          GetInfo = True
      End If
    %>
    </body>
    </html>

    Dear All,

     i am trying to retrive data from ad but its not working, can any one help me.

    if cannot how to do in ASP.net in the similar way

    Did you get an answer? Let me know if you need any help.

    Sunday, June 6, 2010 10:41 AM