Solved

SharePoint user profile services

Posted on 2010-11-20
2
438 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
Comment Utility
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
Comment Utility
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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

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…
Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now