Creating a new managed metadata service application

The managed metadata service application provides the core backend functionality for the managed metadata features in SharePoint. A SharePoint farm may contain one or more managed metadata service applications. Using multiple service applications provides the ability to isolate metadata content between web applications and also provides differing permissions.

In addition to the methods outlined in this recipe, the managed metadata service application can also be provisioned with the Farm Configuration Wizard in Central Administration when configuring the SharePoint farm for the first time.

How to do it...

Follow these steps to create a new managed metadata service application:

  1. Navigate to Central Administration in your preferred web browser.

    Note

    If you are accessing Central Administration on the SharePoint server, you will need to run SharePoint 2013 Central Administration from the Start menu as an administrator.

  2. In the Application Management section, select Manage service applications as shown in the following screenshot:
    How to do it...
  3. From the SERVICE APPLICATIONS tab on the ribbon, navigate to New | Managed Metadata Service:
    How to do it...
  4. Provide a name, database server, and a database name.
  5. Create a new or select an existing Application Pool for the service application to run under.
  6. Click on OK.
  7. On the Manage service applications page, select the row for the new service application (do not click on the link to the service application).
  8. Select Administrators from the SERVICE APPLICATIONS tab on the ribbon:
    How to do it...
  9. Enter your username and click on Add.
  10. Mark the checkbox named Full Control:
    How to do it...
  11. Click on OK.
  12. Select System Settings from the quick launch:
    How to do it...
  13. Select Manage services on server from the Servers section:
    How to do it...
  14. Click on Start for the Managed Metadata Web Service if it is not already started. If you have more than one SharePoint server in the SharePoint farm, you can select the server in the drop-down list at the top of the page for which to manage the services.
    How to do it...

How it works...

Service applications in SharePoint provide the backend web services and access to data storage used by many of the features throughout SharePoint. Multiple service applications of the same type may be used to isolate data between different web applications.

The managed metadata service application provides the web services and access to SQL data storage used by the managed metadata features on the frontend.

Note

Granting yourself full control (administrator) access to the service application provides you with full control over managing the term sets within the service application. Some functionality in the management page for the managed metadata service application will be unavailable if you do not grant full control to yourself. In addition, other users may be added who aren't necessarily farm administrators. If a user who is not a farm administrator is granted access, they will only be able to navigate to the service applications they have access to when they browse to Central Administration.

There's more...

Service applications may also be created with PowerShell or code using the server-side object model.

Creating a new managed metadata service application using PowerShell

Follow these steps to create a new managed metadata service application using PowerShell:

  1. Use the New-SPServiceApplicationPool Cmdlet to create a new application pool to run our new service application and assign it to a variable. Use an existing managed account.
    $pool = New-SPServiceApplicationPool "Managed Metadata Service Application Pool" -Account "domainuser"
    

    Tip

    Alternatively, the Get-SPServiceApplicationPool Cmdlet may be used to retrieve an existing service application pool rather than creating a new one. In addition, to use a new service account rather than an existing one. The New-SPManagedAccount Cmdlet can be used to create it. The account specified must already be registered as a managed account with SharePoint before creating the application pool.

  2. Use the New-SPMetadataServiceApplication Cmdlet to create our new service application:
    $mms = New-SPMetadataServiceApplication -Name "Managed Metadata Service" -ApplicationPool $pool -DatabaseName "ManagedMetadata"
    
  3. Use the New-SPMetadataServiceApplicationProxy Cmdlet to create the proxy to our new service application and add it to the default proxy group:
    New-SPMetadataServiceApplicationProxy –Name "Managed Metadata Service Proxy" -ServiceApplication $mms –DefaultProxyGroup
    
  4. Start the Managed Metadata Web Service by getting the service instances from the SharePoint server with the Get-SPServer Cmdlet:
    (Get-SPServer servername).ServiceInstances | Where-Object { $_.TypeName -eq "Managed Metadata Web Service" } | ForEach-Object { $_.Provision() }
    

Creating a new managed metadata service application with code using the server-side object model

Portions of the server-side object model are not publicly exposed from the SharePoint assemblies. As such, we will use .NET reflection to invoke the methods necessary to create the service application, proxy, and application pool. Follow these steps to create a new managed metadata service application with code using the server-side object model:

  1. Get the NTAccount object for the user account the application pool will run under:
    var account = new NTAccount("domain\user");
  2. Get the SharePoint managed account for the user account:
    var processAccount = SPProcessAccount.LookupManagedAccount((SecurityIdentifier)account.Translate(typeof(SecurityIdentifier)));
  3. Get the types required to instantiate a new application pool:
    var appPoolType = Type.GetType("Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
    
    var appPoolOptionsType = Type.GetType("Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPoolProvisioningOptions, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
    var noneOption = appPoolOptionsType.GetField("None").GetValue(appPoolOptionsType);
  4. Use the Create and BeginProvision methods of the application pool type to create the new application pool:
    var name = "Managed Metadata Service Application Pool";
    
    var createMethod = appPoolType.GetMethod("Create", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(SPFarm), typeof(string), typeof(SPProcessAccount) }, null);
    
    var applicationPool = (SPIisWebServiceApplicationPool)createMethod.Invoke(null, new object[] { SPFarm.Local, name, processAccount });
    
    applicationPool.Update();
    
    var beginProvision = appPoolType.GetMethod("BeginProvision", BindingFlags.Instance | BindingFlags.NonPublic);
    
    beginProvision.Invoke(applicationPool, new object[] { noneOption });
  5. Get the type required to instantiate the managed metadata service application:
    var metadataAppType = Type.GetType("Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplication, Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
  6. Use the Create method on the service application type to create the new service application:
    var createAppMethod = metadataAppType.GetMethod("Create", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(String), typeof(String), typeof(String), typeof(String), typeof(String), typeof(String), typeof(SPIisWebServiceApplicationPool), typeof(String), typeof(bool), typeof(bool), typeof(bool), typeof(int), typeof(int), typeof(bool) }, null);
    
    var mms = createAppMethod.Invoke(null, new object[] { "Managed Metadata Service", "ManagedMetadataDatabase", null, null, null, null, applicationPool, null, false, false, false, 0, 0, false });
  7. Get the Uri property for the newly created service application:
    var mmsUri = (Uri)metadataAppType.GetProperty("Uri", BindingFlags.Instance | BindingFlags.Public).GetValue(mms);
  8. Get the type required to instantiate the service application proxy:
    var metadataProxyAppType = Type.GetType("Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy, Microsoft.SharePoint.Taxonomy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
  9. Use the CreateProxy method to create the service application proxy:
    var createProxyMethod = metadataProxyAppType.GetMethod("CreateProxy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(Uri), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(Uri), typeof(bool), typeof(bool), typeof(bool) }, null);
    
    createProxyMethod.Invoke(null, new object[] { mmsUri, "Managed Metadata Service Proxy", false, false, false, null, false, true, false });
  10. Start the Managed Metadata Web Service on the local SharePoint server:
    ((SPServiceInstance)SPServer.Local.ServiceInstances.Where(p => p.TypeName.Equals("Managed Metadata Web Service", StringComparison.OrdinalIgnoreCase)).First()).Provision();

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.176.5