In InfoPath 2007 you can get the logon name of the current user by using the built-in function username(). (http://blogs.msdn.com/infopath/archive/2006/05/26/608092.aspx)
If you want to get more information that just the user name you should use the UserprofileService Web Service of MOSS. You have two options with this service:
- You can pass the account information of the user who’s details you need
 - You can pass a null value, which will cause the web service to grab the current users identify
 
How to do it:
Step 1: Create the form
- Open InfoPath and design a new, blank form
 - Save the form
 
Step 2: Set the security level of the form
- From the Main Toolbar, select Tools | Form Options
 - Select Security and Trust from the list box
 - Clear the checkbox next to Automatically determine security level
 - Select Full Trust
 - Hit OK.
 
Step 3: Add code to the form
- From the Main Toolbar, select Tools | Programming | Loading Event
 - Right-click on UserProfileDemo node of the Project Explorer and choose Add Web Reference
 - Enter the following for the URL: http://<yourServerName>/_vti_bin/UserProfileService.asmx
 - Enter the following for Web reference name: ProfileService
 - Click Add Reference
 - Replace the FormEvents_Loading event handler with the following code snippet:
 
|           ProfileService.UserProfileService profileService = new Gravity.IP.Activities.SignUp.ProfileService.UserProfileService();             |      
No comments:
Post a Comment