Results 1 to 10 of 10

Thread: [RESOLVED] How do I get the logged on persons actual name?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Resolved [RESOLVED] How do I get the logged on persons actual name?

    How do I get the logged on persons actual name? I already know how to get their logon name but I need their actual first and last name.

    Thanks in advance.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How do I get the logged on persons actual name?

    I don't think that is available unless the user has entered it somewhere.

    One good way is to ask them first what their name is then use that name.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    Addicted Member MasterBlaster's Avatar
    Join Date
    Jul 2002
    Location
    Seattle
    Posts
    196

    Re: How do I get the logged on persons actual name?

    Quote Originally Posted by 2MuchRiceMakesMeSick
    How do I get the logged on persons actual name? I already know how to get their logon name but I need their actual first and last name.

    Thanks in advance.
    Are you using Active Directory and Windows integrated authentication?
    "And most of the evils of society can, in fact, be cured through information. We have a society that has been disinformed and based on the disinformation has made irrational choices. And that's what I mean by 'ignorance.' People, who ordinarily might be smart, are deprived of the data by which to make a rational decision, don't have the data to do it."
    Frank Zappa

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do I get the logged on persons actual name?

    Environment.Username

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: How do I get the logged on persons actual name?

    Quote Originally Posted by MasterBlaster
    Are you using Active Directory and Windows integrated authentication?

    Im not sure. its windows XP sp2




    Quote Originally Posted by mendhak
    Environment.Username
    that returns the USERNAME im looking for the Users actual name

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: How do I get the logged on persons actual name?

    Quote Originally Posted by 2MuchRiceMakesMeSick
    Im not sure. its windows XP sp2






    that returns the USERNAME im looking for the Users actual name
    Thats what is written in the earlier posts, it will just return the Username. I don't think users full name is available anywhere.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do I get the logged on persons actual name?

    Only if it's stored in the ActiveDirectory can you get to the user's "actual name."

    In your code, import System.DirectoryServices, instantiate a new DirectoryEntry object, passing it the LDAP path (it usually looks like LDAP://mydomain) and then create a DirectorySearcher which will filter... wait, let me write a code example, brb.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do I get the logged on persons actual name?

    Code:
    DirectoryEntry de = new DirectoryEntry("LDAP://mydomain");
    DirectorySearcher ds = new DirectorySearcher(de);
    ds.Filter = "(&(objectClass=user)(l=" + Environment.UserName + "))";
    foreach(SearchResult sr in ds.FindAll())
    {
    MessageBox.Show(sr.Properties["givenName"][0].ToString());
    MessageBox.Show(sr.Properties["initials"][0].ToString());
    MessageBox.Show(sr.Properties["ln"][0].ToString());
    }
    HTH

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    121

    Re: How do I get the logged on persons actual name?

    thank you very much!

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How do I get the logged on persons actual name?

    No prob. Add Resolved to the thread title so that other people who have the same question in the future can do a search and completely overlook this post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width