Freigeben über


How to Assign a Stamp to a Tenant

 

Applies To: System Center 2016 - Service Provider Foundation, System Center Technical Preview

In Service Provider Foundation, you can add a stamp instance to a tenant through a link. The link that you create associates the tenant with the stamp instance with each other. By using the service object, you can add a link between two objects by calling the AddLink method, which passes in the source object, the source property name, and the target object. When a stamp is associated with a tenant, a corresponding Virtual Machine Manager (VMM) tenant administrator user role is created on the server that the stamp is assigned to.

To assign a stamp to a tenant

  1. Connect to the Admin service.

  2. Get an existing SpfAdmin.Tenant object.

  3. Get an existing SpfAdmin.Stamp object.

  4. Call the Admin.AddLink method. Pass the tenant instance as the first parameter, and supply the string "Stamps" for the second parameter. Pass the stamp instance for the third parameter.

  5. Call the Admin.SaveChanges method.

Example

The following example connects to the administrative service and creates a new tenant. For more information, seeProgramming in Visual Studio with Service Provider Foundation Services.

  
SpfAdmin.Admin adminService = new SpfAdmin.Admin(new System.Uri(@"https://contoso:8090/SC2012/Admin/Microsoft.Management.Odata.svc/"));  
adminService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;  
  
SpfAdmin.Tenant tenant = adminService.Tenants.Where(t => t.ID == new Guid("1E624759-0B2E-471F-A833-E432F1DB35AB")).FirstOrDefault();  
SpfAdmin.Stamp stamp = adminService.Stamps.Where(s => s.ID == new Guid("1ABD8C2B-977C-4511-AD68-ACAF6F923B82")).FirstOrDefault();  
  
if (stamp != null && tenant != null)  
{  
    adminService.AddLink(tenant, "Stamps", stamp);  
    adminService.SaveChanges();  
}  
  

Compiling the Code

Assemblies

System
System.Core

Namespaces

System
System.Linq

See Also

Tenants
Overview
How to Create a New Tenant