Infopath using Windows User's name - InfoPath Dev
in

InfoPath Dev

Infopath using Windows User's name

Last post 05-01-2014 11:42 AM by james28. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 04-30-2014 02:35 PM

    Infopath using Windows User's name

    Hello all!

     

     In Windows 7 and Infopath 2010, I am trying to pull the user's name into infopath. I was able to find the function that pulls the logged in users log in username, which is great, but I also want to be able to pull the actual person's name that is associated with the user account.

     

    The name I am referring to is visible in Windows 7 on the start menu. I found this image online showing what I mean. You can ignore the stuff in the background of the image, I am only interested in the name. In the case of this image, "Andy Walker". 

    http://docs.oracle.com/cd/E36500_01/E36502/html/images/win7-desktop-web.png

     

     

    Does anyone have any idea how to pull that name into infopath? 

     

    Thank you very much for any suggestions that you may have!

     

     

     

  • 04-30-2014 04:40 PM In reply to

    • rcranney
    • Not Ranked
      Male
    • Joined on 04-25-2013
    • Arizona
    • Posts 5

    Re: Infopath using Windows User's name

    Will the form be published to a SharePoint site?
  • 04-30-2014 04:55 PM In reply to

    Re: Infopath using Windows User's name

    rcranney, Thank you for your reply! No, there will be no sharepoint involvement. Everything is stored in an Access database on the local network.
  • 04-30-2014 06:09 PM In reply to

    • rcranney
    • Not Ranked
      Male
    • Joined on 04-25-2013
    • Arizona
    • Posts 5

    Re: Infopath using Windows User's name

    Give this a try...

    • Add 'using System.DirectoryServices.AccountManagement;'
    • Add Reference to System.DirectoryServices.AccountManagement

    THEN

    // Create UserPrinciple Object and set it to the current USER...
    UserPrincipal userPrincipal = UserPrincipal.Current;
    // Set name variable to the DisplayName of current user.
    String name = userPrincipal.DisplayName;
    // If President Obama was the current user, name would have a string value of "Obama, Barrack"

    Found the code here

  • 04-30-2014 07:31 PM In reply to

    Re: Infopath using Windows User's name

    rcranney, Thank you again for the reply. Unfortunately, I do not exactly understand. What exactly do I do with that code? I think what you were trying to post was cut off. You said you found the code "here", but there is no link or anything.
  • 05-01-2014 11:11 AM In reply to

    • rcranney
    • Not Ranked
      Male
    • Joined on 04-25-2013
    • Arizona
    • Posts 5

    Re: Infopath using Windows User's name

    I edited my last post, fixed the HTML tags and added in comments..
  • 05-01-2014 11:42 AM In reply to

    Re: Infopath using Windows User's name

    rcranney, Thank you again for the reply and for the clarification. I am still some what of a novice, so I do not understand exactly where to begin. Am I putting this code in the function of a text box, the "code editor", or something else completely. Any additional steps or guidance would be greatly appreciated. Thanks again
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.