Share via


ServiceAccount

[This documentation is preliminary and is subject to change.]

The ServiceAccount object represents the user account for the AD RMS service account. You can retrieve this object by calling the CurrentServiceAccount property on the ServiceIdentity object.

When you provision AD RMS on a server, you must define a service account and specify the account credentials. If the SQL server is shared by more than one AD RMS installation, the service account must be a domain account, but not the same domain account that you used to install AD RMS. The service account is made a member of the RMS Service Group, and is granted the permissions of that group.

Methods

The ServiceAccount object defines the following method.

Method Description
ToString Retrieves the localized account name.

Properties

The ServiceAccount object has the following properties.

Property Description
Type Specifies or retrieves the service account type.
UserDomainAccount Retrieves an object that contains the account credentials.

Example Code [VBScript]

DIM config_manager
DIM admin_role

' *******************************************************************
' Create and initialize a ConfigurationManager object.

SUB InitObject()

  CALL WScript.Echo( "Create ConfigurationManager object...")
  SET config_manager = CreateObject _
    ("Microsoft.RightsManagementServices.Admin.ConfigurationManager")      
  CheckError()
    
  CALL WScript.Echo( "Initialize...")
  admin_role=config_manager.Initialize(false,"localhost",80,"","","")
  CheckError()

END SUB

' *******************************************************************
' Retrieve the current account and change it.

SUB ChangeServiceAccount()

  DIM chngMgr
  DIM newAcct

  DIM dType
  dType = config_manager.Constants.ServiceAccountTypeDomainIdentity

  ' Create a ServiceIdentity object that can be used to change the 
  ' service account.
  SET chngMgr = config_manager.ServiceIdentity
  CheckError()

  ' Create a new account.
  SET newAcct = chngMgr.NewServiceAccount
  CheckError()

  newAcct.Type = dType
  newAcct.UserDomainAccount.Domain = "domain_name"
  newAcct.UserDomainAccount.UserId = "User_id"
  newAcct.UserDomainAccount.Password = "password"

  ' Update service account with the new account information.
  chngMgr.Update()
  CheckError()

END SUB

' *******************************************************************
' Error checking function.

FUNCTION CheckError()
  CheckError = Err.number
  IF Err.number <> 0 THEN
    CALL WScript.Echo( vbTab & "*****Error Number: " _
                       & Err.number _
                       & " Desc:" _
                       & Err.Description _
                       & "*****")
    WScript.StdErr.Write(Err.Description)
    WScript.Quit( Err.number )
  END IF
END FUNCTION

Requirements

Product Requires Windows Server "Longhorn".
Library

Use Microsoft.RightsManagementServices.Admin.dll registered as a custom type library.

See Also

Active Directory Rights Management Services Scripting API