SecureEnvironment.Create 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個安全的客戶端會話以進行權利管理作業。
多載
| 名稱 | Description |
|---|---|
| Create(String, ContentUser) |
為指定使用者建立一個擁有特定權限清單的安全用戶端會話。 |
| Create(String, AuthenticationType, UserActivationMode) |
根據應用程式權限清單、 AuthenticationType、 UserActivationMode和 ,建立一個安全的客戶端會話。 |
範例
以下範例說明如何使用此方法建立安全環境。
string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
StreamReader manifestReader = File.OpenText("rpc.xml");
applicationManifest = manifestReader.ReadToEnd();
}
if (_secureEnv == null)
{
if (SecureEnvironment.IsUserActivated(new ContentUser(
_currentUserId, AuthenticationType.Windows)))
{
_secureEnv = SecureEnvironment.Create(
applicationManifest, new ContentUser(
_currentUserId, AuthenticationType.Windows));
}
else
{
_secureEnv = SecureEnvironment.Create(
applicationManifest,
AuthenticationType.Windows,
UserActivationMode.Permanent);
}
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
applicationManifest = manifestReader.ReadToEnd()
End If
If _secureEnv Is Nothing Then
If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
_secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
Else
_secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
End If
End If
Create(String, ContentUser)
為指定使用者建立一個擁有特定權限清單的安全用戶端會話。
public:
static System::Security::RightsManagement::SecureEnvironment ^ Create(System::String ^ applicationManifest, System::Security::RightsManagement::ContentUser ^ user);
public static System.Security.RightsManagement.SecureEnvironment Create(string applicationManifest, System.Security.RightsManagement.ContentUser user);
static member Create : string * System.Security.RightsManagement.ContentUser -> System.Security.RightsManagement.SecureEnvironment
Public Shared Function Create (applicationManifest As String, user As ContentUser) As SecureEnvironment
參數
- applicationManifest
- String
應用權利的明確性。
- user
- ContentUser
授權存取權限管理內容的使用者或使用者群組。
傳回
一個安全的用戶端會話,用於啟用、授權綁定及其他權利管理操作。
範例
以下範例說明如何使用此方法建立安全環境。
string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
StreamReader manifestReader = File.OpenText("rpc.xml");
applicationManifest = manifestReader.ReadToEnd();
}
if (_secureEnv == null)
{
if (SecureEnvironment.IsUserActivated(new ContentUser(
_currentUserId, AuthenticationType.Windows)))
{
_secureEnv = SecureEnvironment.Create(
applicationManifest, new ContentUser(
_currentUserId, AuthenticationType.Windows));
}
else
{
_secureEnv = SecureEnvironment.Create(
applicationManifest,
AuthenticationType.Windows,
UserActivationMode.Permanent);
}
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
applicationManifest = manifestReader.ReadToEnd()
End If
If _secureEnv Is Nothing Then
If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
_secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
Else
_secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
End If
End If
備註
此 Create 方法適用於已啟用的使用者,例如從 返回 GetActivatedUsers的列表中提供的。 對於尚未啟用的使用者,請使用替代 Create 方式。
另請參閱
適用於
Create(String, AuthenticationType, UserActivationMode)
根據應用程式權限清單、 AuthenticationType、 UserActivationMode和 ,建立一個安全的客戶端會話。
public:
static System::Security::RightsManagement::SecureEnvironment ^ Create(System::String ^ applicationManifest, System::Security::RightsManagement::AuthenticationType authentication, System::Security::RightsManagement::UserActivationMode userActivationMode);
public static System.Security.RightsManagement.SecureEnvironment Create(string applicationManifest, System.Security.RightsManagement.AuthenticationType authentication, System.Security.RightsManagement.UserActivationMode userActivationMode);
static member Create : string * System.Security.RightsManagement.AuthenticationType * System.Security.RightsManagement.UserActivationMode -> System.Security.RightsManagement.SecureEnvironment
Public Shared Function Create (applicationManifest As String, authentication As AuthenticationType, userActivationMode As UserActivationMode) As SecureEnvironment
參數
- applicationManifest
- String
應用權利的明確性。
- authentication
- AuthenticationType
認證的方法。
- userActivationMode
- UserActivationMode
使用者權利帳號憑證的類型。
傳回
一個安全的用戶端會話,用於啟用、授權綁定及其他權利管理操作。
範例
以下範例說明如何使用此方法建立安全環境。
string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
StreamReader manifestReader = File.OpenText("rpc.xml");
applicationManifest = manifestReader.ReadToEnd();
}
if (_secureEnv == null)
{
if (SecureEnvironment.IsUserActivated(new ContentUser(
_currentUserId, AuthenticationType.Windows)))
{
_secureEnv = SecureEnvironment.Create(
applicationManifest, new ContentUser(
_currentUserId, AuthenticationType.Windows));
}
else
{
_secureEnv = SecureEnvironment.Create(
applicationManifest,
AuthenticationType.Windows,
UserActivationMode.Permanent);
}
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
applicationManifest = manifestReader.ReadToEnd()
End If
If _secureEnv Is Nothing Then
If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
_secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
Else
_secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
End If
End If
備註
此 Create 方法適用於尚未啟用的新用戶。
啟用新使用者需進行伺服器往返交易,以取得使用者憑證與用戶端授權憑證。
當使用者已經啟用時,可以使用另一種 Create 方法,例如從 返回 GetActivatedUsers的清單中所提供的。