Solved

SharePoint user profile services

Posted on 2010-11-20
2
459 Views
Last Modified: 2012-05-10
I used the getuserprofilebyname() method to obtain information about the current user in InfoPath form.

My question is:
How can we pass in an account name or username to this data connection to obtain information (i.e. email addres, department, full name, etc) about other user(s)..?
0
Comment
Question by:sraj09
2 Comments
 
LVL 7

Assisted Solution

by:AlMothanaAlOmari
AlMothanaAlOmari earned 250 total points
ID: 34183029
public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            XPathNavigator root = this.MainDataSource.CreateNavigator();
            using (SPSite ospSite = new SPSite("http://sharepoint2010"))
   {
                try
                {
                    string uAccount =System.Environment.UserName;
                    string uManager;
                    string uPosition;
                    string uDepratment;

                    ServerContext ospServerContext = ServerContext.GetContext(ospSite);
                    UserProfileManager ospUserProfileManager = new UserProfileManager(ospServerContext);
                    UserProfile ospUserProfile = ospUserProfileManager.GetUserProfile(uAccount);


                   uManager= ospUserProfile["Name"].Value.ToString();
                   uPosition= ospUserProfile["Manager"].Value.ToString();
                   uDepratment= ospUserProfile["Department"].Value.ToString();
                   

                    root.SelectSingleNode("/my:VacationForm/my:EmployeeName", NamespaceManager).InnerXml =uAccount;
                    root.SelectSingleNode("/my:VacationForm/my:ManagerName", NamespaceManager).InnerXml = uManager;

                    root.SelectSingleNode("/my:VacationForm/my:Position", NamespaceManager).InnerXml = uPosition;

                    root.SelectSingleNode("/my:VacationForm/my:Department", NamespaceManager).InnerXml = uDepratment;

                   
                }

                catch (Exception ex)
                {
                   
                }
            }
0
 
LVL 15

Accepted Solution

by:
melli111 earned 250 total points
ID: 34187869
How is your form setup?  Assuming that a user is selecting lets say a manager somewhere and you're storing that account name, you would set a rule on that account name field.  the rule would be  "set a fields value" ... that value you would set would be the AccountName filed in the queryFields node of the GetUserProfileByName data source.  The value would be that username value that was just set on the field we're running the rule from.  Add a second action of "Query Using a Data Connection" to query the GetUserProfileByName service again... if you don't query it, it will not pull the new information.  

I hope that helps... let me know if you need any clarification.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question