Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SharePoint user profile services

Posted on 2010-11-20
2
Medium Priority
?
481 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 1000 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 1000 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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