Solved

SharePoint user profile services

Posted on 2010-11-20
2
474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.

737 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