how to get data from Active Directory?

Discussion in 'ASP .Net' started by Luc, Jan 19, 2010.

  1. Luc

    Luc Guest

    Hi,

    users log in with their personal number (5 digits) in our intranet. For each
    number, there is a name associated in the Active Directory of the domain
    server.

    Now, there is an asp.net application which read the number
    (Request.ServerVariables("remote_user")).
    My question is: is it possible to get the name from the AD in the
    application?
    Thanks
    Luc
     
    Luc, Jan 19, 2010
    #1
    1. Advertising

  2. On Jan 19, 1:25 pm, "Luc" <> wrote:
    > Hi,
    >
    > users log in with their personal number (5 digits) in our intranet. For each
    > number, there is a name associated in the Active Directory of the domain
    > server.
    >
    > Now, there is an asp.net application which read the number
    > (Request.ServerVariables("remote_user")).
    > My question is: is it possible to get the name from the AD in the
    > application?
    > Thanks
    > Luc


    Hi Luc,

    yes, you can do it, for example, by doing LDAP request. LDAP is a
    protocol for querying and modifying directory services.

    Read more about System.DirectoryServices at
    http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx

    Example of the code you have

    DirectoryEntry de = new DirectoryEntry(ldapPath);
    DirectorySearcher ds = new DirectorySearcher(de);
    ds.Filter = "(name=12345)"; // where 12345 is your name
    SearchResult sr = ds.FindOne();
    DirectoryEntry do = sr.GetDirectoryEntry();
    Response.Write ((string)do.Properties["displayName"].Value); // where
    displayName is default standard name for full name

    Hope this helps
     
    Alexey Smirnov, Jan 19, 2010
    #2
    1. Advertising

  3. On Jan 19, 2:05 pm, Alexey Smirnov <> wrote:
    > On Jan 19, 1:25 pm, "Luc" <> wrote:
    >
    > > Hi,

    >
    > > users log in with their personal number (5 digits) in our intranet. For each
    > > number, there is a name associated in the Active Directory of the domain
    > > server.

    >
    > > Now, there is an asp.net application which read the number
    > > (Request.ServerVariables("remote_user")).
    > > My question is: is it possible to get the name from the AD in the
    > > application?
    > > Thanks
    > > Luc

    >
    > Hi Luc,
    >
    > yes, you can do it, for example, by doing LDAP request. LDAP is a
    > protocol for querying and modifying directory services.
    >
    > Read more about System.DirectoryServices athttp://msdn.microsoft.com/en-us/library/system.directoryservices.aspx
    >
    > Example of the code you have
    >


    Example of the code you CAN have
     
    Alexey Smirnov, Jan 19, 2010
    #3
  4. Luc

    Luc Guest

    Thanks Alexey ...

    "Alexey Smirnov" <> schreef in bericht
    news:...
    On Jan 19, 2:05 pm, Alexey Smirnov <> wrote:
    > On Jan 19, 1:25 pm, "Luc" <> wrote:
    >
    > > Hi,

    >
    > > users log in with their personal number (5 digits) in our intranet. For
    > > each
    > > number, there is a name associated in the Active Directory of the domain
    > > server.

    >
    > > Now, there is an asp.net application which read the number
    > > (Request.ServerVariables("remote_user")).
    > > My question is: is it possible to get the name from the AD in the
    > > application?
    > > Thanks
    > > Luc

    >
    > Hi Luc,
    >
    > yes, you can do it, for example, by doing LDAP request. LDAP is a
    > protocol for querying and modifying directory services.
    >
    > Read more about System.DirectoryServices
    > athttp://msdn.microsoft.com/en-us/library/system.directoryservices.aspx
    >
    > Example of the code you have
    >


    Example of the code you CAN have
     
    Luc, Jan 19, 2010
    #4
  5. On Jan 19, 3:07 pm, "Luc" <> wrote:
    > Thanks Alexey ...
    >


    No problem... I forgot to mention that ldapPath is a path to your
    server, e.g. LDAP://server:389/OU=Users,DC=Test,DC=COM
     
    Alexey Smirnov, Jan 19, 2010
    #5
    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. =?Utf-8?B?RGFuIE5hc2g=?=

    get user details from Active Directory

    =?Utf-8?B?RGFuIE5hc2g=?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    28,495
    Eddy Jawed
    Jun 2, 2010
  2. Ronen Diment
    Replies:
    1
    Views:
    849
    Olaf Lenzmann
    Dec 9, 2003
  3. ejcosta
    Replies:
    2
    Views:
    874
    Eurico Costa
    Oct 8, 2004
  4. Shaker
    Replies:
    5
    Views:
    170
    Joe Kaplan \(MVP - ADSI\)
    Dec 20, 2004
  5. Lin Ma

    Get userID from Active Directory.

    Lin Ma, Sep 22, 2003, in forum: ASP General
    Replies:
    7
    Views:
    578
Loading...

Share This Page