Ads

Showing posts with label User Profile. Show all posts
Showing posts with label User Profile. Show all posts

Tuesday, 15 May 2018

Steps to consume user profile from different sharepoint farm

Step 1. Set up the Application Discovery and Load Balancer Service Application

Before any farm can provide services to another farm, the consuming farm must be able to use the Application Discovery and Load Balancer Service. This is also known as the Topology Service. The part we are concerned with here is the Application Discovery piece. The consumer needs rights to use the service so that it can find the proxies on the publishing farm. To do this you need to follow these steps.
1.      On the Consumer farm.
a.      Open up SharePoint 2010 Management Shell
b.      Type in (Get-SPFarm).Id
c.      Copy the output to notepad (or just keep it open so you can type it in)
2.      On the Publishing farm.
a.      Open up SharePoint 2010 Management Shell
b.      Type in $security = Get-SPTopologyServiceApplication | Get-SPServiceApplicationSecurity
c.      Then type $claimProvider = (Get-SPClaimProvider System).ClaimProvider
d.      Then type $principal = New-SPClaimsPrincipal -ClaimType "http://schemas.microsoft.com/sharepoint/2009/08/claims/farmid" -ClaimProvider $claimProvider -ClaimValue paste the farm id from step 1 here just as it appeared
e.      Then type Grant-SPObjectSecurity -Identity $security -Principal $principal -Rights "Full Control"
f.       Then type Get-SPTopologyServiceApplication | Set-SPServiceApplicationSecurity -ObjectSecurity $security


Step 2. Create your certificates. You need to exchange certificates between servers. The consumer will need the Root certificate of the publishing farm, but the publishing farm will need the Root certificate of the consumer and the STS (Security Token Service) certificate. You can go to the TechNet article here http://technet.microsoft.com/en-us/library/ee704552.aspx or follow these steps.
1.      On the consumer farm
a.      Open up SharePoint 2010 Management Shell
b.      Type  $rootCert = (Get-SPCertificateAuthority).RootCertificate
c.      Then Type $rootCert.Export("Cert") | Set-Content C:\ConsumingFarmRoot.cer -Encoding byte
d.      You now have the root certificate for the consuming server on the C drive of the consuming server. Next we get the STS certificate.
e.      Type $stsCert = (Get-SPSecurityTokenServiceConfig).LocalLoginProvider.SigningCertificate
f.       Then Type $stsCert.Export("Cert") | Set-Content C:\ConsumingFarmSTS.cer -Encoding byte
g.      You now have the STS Token for the consuming farm.
h.      Make the two files you created available to the publishing farm (i.e. copy them to the publishing farm)
2.      On the publishing farm.
a.      Open up SharePoint 2010 Management Shell
b.      Type  $rootCert = (Get-SPCertificateAuthority).RootCertificate
c.      Then Type $rootCert.Export("Cert") | Set-Content <C:\PublishingFarmRoot.cer> -Encoding byte
d.      Make the file available on the consuming farm.

Step 3. Import the certificates.
1.      Import the consumer root certificates on the publishing server.
a.      Open up SharePoint 2010 Management Shell on the publishing server
b.      Type $trustCert = Get-PfxCertificate C:\ConsumingFarmRoot.cer (replace c:\publishingfarmroot.cer with the location of the consuming server root cert)
c.      Then Type New-SPTrustedRootAuthority type the name of the consuming server here  -Certificate $trustCert
d.      The certificate should print to the screen if it was successful
2.  Import the consumer STS certificate on the publishing server
a.      Open up SharePoint 2010 Management Shell on the publishing server
b.      Type $stsCert = Get-PfxCertificate c:\ConsumingFarmSTS.cer (replace c:\consumingfarmsts.cer with location of consuming server STS cert)
c.      Then type New-SPTrustedServiceTokenIssuer type the name of consuming server -Certificate $stsCert
d.      The certificate should print to the screen if it was successful
3.  Import the publishing root certificate on the consuming server
a.      Open up SharePoint 2010 Management Shell on the consuming server
b.      Type $trustCert = Get-PfxCertificate C:\PublishingFarmRoot.cer (replace c:\publishingfarmroot.cer with the location of the publishing farm root cert)
c.      The certificate should print to the screen if it was successful

Step 3. Publish the service. You have to publish the service from the publishing server before it can be consumed. The easiest way to do this is from Central Administration
1.      Navigate to the central administration of the publishing server.
2.      Click on Manage service applications
3.      Click on the User Profile Service (off to the right of it. You don’t want to manage it just highlight it)
4.      Click on the Publish icon at the top of the page.
5.      Make sure the Publish this Service Application to other farms is checked.
6.      Copy the Published URL. It is a really long thing that looks similar to this urn:schemas-microsoft-com:sharepoint:service:6f63cdec5e784a02b2b79f9bf91346af#authority=urn:uuid:daf0ec20a27a44c7abe5104b5d516637&authority=https://orsps01:32844/Topology/topology.svc 
7.      Click OK. You are done with the publishing server now.
Step 4. Consume the service.
1.      Open up the Central Administration of the consuming server.
2.      Click on Manage service applications
3.      Click on the Connect icon on the top ribbon and choose User Profile Service Application Proxy
4.      In the Connect to a Remote Service Application dialog paste the Url from Step 3 (yours, not the example above)
5.      Click OK. You should see a screen that shows the connection (or an error page if it didn’t)
6.      Highlight User Profile Service and click OK.
7.      You should get a confirmation screen and click OK again.
You have now consumed the User Profile Service. That means when a user updates their profile data it will be the same on both farms. It will use the trusted My Site locations, the audiences, etc. from the publishing farm. Therefore if you want to add/modify anything  for the consumer farm it needs to be done on the central administration of the publishing farm.
Share service applications across farms in SharePoint Server

Wednesday, 23 April 2014

Export sharepoint user profile properties to excel using C#

This is a short guide on how to export the properties from a Sharepoint 2010 user profile database into a spreadsheet using a simple C# script.

Our end result is to get this export into a format something like:


  1. Open Visual Studio
  2. Create new project - Visual C# > Consolse Application

  1. Name it UserProfileDataExtract
  2. Add the missing references below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
namespace UserProfileDataExtract
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Accessing mysite.......");
 
            //This is the mysite location
            SPSite site = new SPSite("http://mysite/people");

            Console.WriteLine("Site Accessed.......");

            StringBuilder sb = new StringBuilder(); 
 
            //Creating headers in the first row
  sb.Append("Username,"); sb.Append("Firstname,"); sb.Append("Lastname,"); sb.Append("Phone,"); sb.Append("Mobile,");
            sb.Append("Email,");
            sb.Append("Manager,");
            sb.Append("JobTitle,");
            sb.Append("\r\n");
  
            Console.WriteLine("Using Site.......");
            using (site)
            {
                Console.WriteLine("Get Context and profile manager.......");
                SPServiceContext context = SPServiceContext.GetContext(site);
                UserProfileManager profileManager = new UserProfileManager(context);

                //Loop through all the user profiles in the sharepoint database
                Console.WriteLine("Starting Loop.......");
                foreach (UserProfile profile in profileManager)
                {
                   //Retrieve the profileimage values for current user
                    string strName = Convert.ToString(profile[PropertyConstants.UserName].Value);
                    string FName = Convert.ToString(profile[PropertyConstants.FirstName].Value);
                    string LName = Convert.ToString(profile[PropertyConstants.LastName].Value);
                    string Phone = Convert.ToString(profile[PropertyConstants.WorkPhone].Value);
                    string Mobile = Convert.ToString(profile[PropertyConstants.CellPhone].Value);
                    string Email = Convert.ToString(profile[PropertyConstants.WorkEmail].Value);
                    string Manager = Convert.ToString(profile[PropertyConstants.Manager].Value);
                    string JobTitle = Convert.ToString(profile[PropertyConstants.JobTitle].Value);
                    Console.WriteLine("Processing: " + strName);
sb.Append(strName + ","); sb.Append(FName + ","); sb.Append(LName + ","); sb.Append(Phone + ","); sb.Append(Mobile + ","); sb.Append(Email + ","); sb.Append(Manager + ","); sb.Append(JobTitle.Replace(",", "-") + ",");
                    sb.Append("\r\n");
               }
          Console.WriteLine("Finished profile retrieval");
          Console.WriteLine("Writing to csv file");
          //Write the long string to a csv file and save it to the desktop
          TextWriter tw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "SharePointUserData.csv");
          tw.WriteLine(sb.ToString());
          tw.Close(); 
          } 
      }//End Main
    }//End class
 }

Wednesday, 22 May 2013

User Profile Configuration 2010

In This Artical I will explain how to set Up and Configure My Sites In SharePoint 2010.

Introduction

In this Article I am going to explain how to configure and Create My Sites for Individual AD users In SharePoint 2010.

For Configuring My Site, I need to Pull Users from Active Directory by using User Profile Service Application.
So Before Creating and Configuring User Profile Service Application, Let’s Understand My SharePoint Environment.


In Active Directory I have one organizational Unit named as “SharePoint” where users are created.

As Shown in Red mark
a)  SharePoint_Admin User Is an Administrator of SharePoint Server 2010.
b)  SharePoint _Farm User Is a SharePoint Farm Administrator.
c)  SharePoint_Service Is a Service Account to handle various Service Applications in SharePoint (such as Search Service Application)

Before Creating User Profile Service Application, ensure.
a)  SharePoint_Admin and SharePoint _Farm User are in local administrator group on computer NDJ(SharePoint Server 2010)
b)  Go to Administrative Tools and Select Services and under services ensure that Startup Type of “Forefront Identity Manager Service” and “Forefront Identity Manager Synchronization Service” is automatic (It Should not be disabled). Note: Do not start manually. It will start automatically.
c)  Go to Administrative tools and select IIS Manager and under Application Pools ensures that “SharePoint Web Services Root “has started. If not, start it.

User Profile Service Application

User Profile Service Application is a shared Application of SharePoint 2010 used to manage user’s profiles of organization, synchronizing profiles with active directory and crating My Sites for users.
So let’s create User Profile Service Application.
1)  Open SharePoint 2010 Central Administration
2)  On Quick Launch, Click on Application Management and then click “Manage Service Applications” Under Service Applications Section.

3)  On Manage Service Application Page click on “New” and select User Profile Service Application.

4)  On Create New User Profile Service Application window type
    a)  Name : User Profile Service Application1
    b)  Application Pool Name : UserProfileServicePool
    c)  Configurable : POINT\Sharepoint_Farm User
After typing these values click on “Create” Button at down.

Service Application will create. After Creating Service Application, we will start necessary services for service application
5)  On Quick Launch menu of central Administration site click on “System Settings” then click on “Manage Services on Server” Under servers Section.

6)  On Services on Server window find out
    a)  User Profile Service and click on start.
    b)  User Profile Synchronization Services and click start.

As soon we click on start we will have User Profile Synchronization Service Window.

On that window ensure that
    a)  “Select the User Profile Application” Is “User Profile Service Application1”
    b)  “Service Account” Is “POINT\SharePoint_Farm” and type Password, click on ok.
    c)  Now a timer job called “ProfileSynchronizationSetupJob” is created. When that job gets completed, a service “User Profile Synchronization Services” will also get started.
7)  To see timer job, on Quick Launch of central Administration site , click on Monitoring and then click on check job status under timer jobs section.

Under Running Jobs We Must have “ProfileSynchronizationSetupJob”.

NOTE: SharePoint server May take some Minute (up to 5) to start that job and get appear in Running Job List.
If Your Job does not start then Restart “SharePoint 2010 Timer” Service (Go to Administrative tools then select services) and again follow step 6.
NOTE: 5 to 15 Minute is required to complete this job. Press F5 to monitor status of this job once it disappears, means job has completed.
8)  Ensure that both the services have started.
    a)  User Profile Service.
    b)  User Profile Synchronization Services.
On Quick Launch menu of central Administration click on “System Settings” then “Manage Services on Server” Under servers Section and check it.

9)  Also ensure that Forefront Identity Manager Service and Forefront Identity Manager Synchronization Service Has started.
Go to Administrative Tools then click on Services and check it.

Restart IIS Server.
    a)  Go to start, right click on command prompt, then click run as administrator.
    b)  Type IISRESET
11)  Now open our service application
On Quick Launch of central Administration site, click Application Management then “Manage Service Applications”, then “User Profile Service Application1” Link. We will have following page, where we can manage user profiles, synchronization with Active Directory, setup My Sites etc.

Now we have created User Profile Service Application, now it’s time to pull our active directory users from AD/DNS server.
NOTE: To do User Profile Synchronization with Active Directory, User SharePoint_Farm (who is Managing User Profile Service Application1) must have Permission to do synchronization. To assign permission use following snapshot
NOTE: We are working from SharePoint Server Machine Named as NDJ.

Assign Permission to user Sharepoint_Farm for synchronization

1)  Click on Administrative tools, Hold down shift key of keyboard and then right click on “Active Directory Users and Computers” and then click “Run as different Users”.

2)  Login as Domain Administrator


3)  Right Click on POINT.COM and then click delegate control.


4)  Click next on “welcome to the delegation control wizard” window and add user “POINT\SharePoint_Farm” to delegate permission and click on next.


5)  On “ task to delegate window” choose  ‘create a custom task to delegate’

6)  On Active Directory object type select “This Folder………”


7)  On Permissions window select “Replicating Directory Changes” and click on next.


8)  Click on finish button.
Here we have assign permission for synchronization with active directory.
Now Next step is to establish connection with Active Directory.

Creating connection with Active Directory

1)  On Quick Launch of central Administration Site, click Application Management then “Manage Service Applications”, then “User Profile Service Application1” Link.


Note on right corner: number of user Profiles are 0.
On this Page click on “Configure Synchronization Connections”
2)  On Synchronization Connections page click on “Create New Connection”


3)  On add new synchronization connection page use following values.
    a)  Connection Name: POINT Active Directory Users.
    b)  Type : Active directory
    c)  Forest Name : POINT.COM
    d)  Account Name : POINT\SharePoint_Farm

Click on Populate Containers and choose SharePoint and Users organizational unit where users are available. And click on ok.

4)  On Quick Launch of central Administration, click Application Management then “Manage Service Applications”, then “User Profile Service Application1” Link.

 And click on “Start Profile Synchronization”. Synchronization Process will start; look at right side on page we have status “Synchronizing”



It will take 10 to 15 to finish this process. Press F5 until Synchronization status is Idle

Look above result, we have number of user profiles = 21 and profile synchronization status is Idle.
Here we have finished synchronization process now it’s time to create and Configure My Sites Host web application.

Configuring My Sites

1)  Now its time Create one New Web Application.
On Quick Launch of Central Administration, Click Application Management and then click Manage Web Applications.
On Web Application Management Page, click on New to create web Application and type necessary parameters and click on ok.


On Application created window click on Create Site Collection.


On Create Site collection Page type following Information and Click Ok
Title – My Site Host
Template – My Site Host under Enterprise Tab
Site Administrator – POINT\SharePoint_Admin

2)  Create Managed Path for My Sites.
On Quick Launch of Central Administration, Click Application Management and then click Manage Web Applications.
Select our SharePoint -112 Web Application and then click on Managed Paths on ribbon.

On Define Managed Paths page add a new Path “social”, Click on Add path and click ok.

3)  Enable self-service site creation for the SharePoint – 112 Web application.
On Quick Launch of Central Administration, Click Application Management and then click Manage Web Applications.
Select our SharePoint -112 Web Application and then click on Self-Service Site Creation on ribbon.

On Self-Service Site Collection Management Page select “ON” and click on OK.

4)  Configure My Sites
On Quick Launch of Central Administration, Click Application Management and then click Manage Web Applications.
Click on Manage service applications, Under Service Applications section and Click on User Profile Service Application1
On User Profile Service Application1 Page click on Setup My Sites under My Site Settings Section.

On My Site Setting Page type
    a)  Preferred Search Center – http://ndj:111/Pages (Address of Enterprise Search Center)
To Setup Enterprise Search follow My Previous Post at (http://www.dotnetfunda.com/articles/article1259-enterprise-people-search-in-sharepoint-2010-.aspx )
    b)  My Site Host – http://ndj:112/ (Address of My Site Host Web Application)
    c)  Personal Site Location : social (Managed Path)

5)  Now Its time to create site for user
Login on Machine by another AD user and open our My Site Host web Application
http://ndj:112/

And click on My Profile, We will get user profile as per information in AD.

And Now Click on “My Content” Link. It will create Personal Web Site for logged user.
NOTE: It will take up to 5 Minute to create web site.

Hope this would be useful for readers..! Thanks and do let me know your comments or feedback.
Reference:
http://technet.microsoft.com/en-us/library/ee624362.aspx
http://technet.microsoft.com/en-us/sharepoint/ee410529

Wednesday, 3 April 2013

C# code to Copy users from user profile to site users

Here we copy all users from user profile to one site.


First, taken an object for your web in which you want to copy users.
You will need these references of assemblies.

using System;
using System.Windows.Forms;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.Office.Server;
using Microsoft.SharePoint;

and then writen down the following code. Just make sure that you have administrative rights to perform this operation.

SPSite objSite = new SPSite("{site URL}");
//Then obtain server context,
ServerContext svrContext = ServerContext.GetContext(objSite);
//Take User profile object
UserProfile myProfile = null;
UserProfileManager profileManager = new UserProfileManager(svrContext);
//Open the web.
SPWeb web = objSite.OpenWeb();
web.AllowUnsafeUpdates = true;
//Navigate through each user profile in profile manager
//and then add the users to the site with its login name.

foreach (UserProfile userprofile in profileManager)
{
if (profileManager.UserExists(userprofile.MultiloginAccounts[0]))
{
web.SiteUsers.Add(userprofile.MultiloginAccounts[0], "", "", "");
}
}

web.Update();

web.AllowUnsafeUpdates = false;

After performing this operation, just wait for some time. This is because initially you may see users Account name as DomainName\UserName, However after some time, These user names will be converted to the Actual user names.(the one that we see after welcome {user name} on top right corner).


Ads