SecureEnvironment.User 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得建立 SecureEnvironment 時指定的使用者或使用者群組。
public:
property System::Security::RightsManagement::ContentUser ^ User { System::Security::RightsManagement::ContentUser ^ get(); };
public System.Security.RightsManagement.ContentUser User { get; }
member this.User : System.Security.RightsManagement.ContentUser
Public ReadOnly Property User As ContentUser
屬性值
建立 Create(String, ContentUser) 時,指定給 SecureEnvironment 方法的使用者或使用者群組。
範例
下列範例示範如何使用 User 屬性
ShowStatus(" Initiating SecureEnvironment as user: \n " +
currentUserId + " [" + _authentication + "]");
if (SecureEnvironment.IsUserActivated(
new ContentUser(currentUserId, _authentication)))
{
ShowStatus(" User is already activated.");
_secureEnv = SecureEnvironment.Create(applicationManifest,
new ContentUser(currentUserId, _authentication));
}
else // if user is not yet activated.
{
ShowStatus(" User is NOT activated,\n activating now....");
// If using the current Windows user, no credentials are
// required and we can use UserActivationMode.Permanent.
_secureEnv = SecureEnvironment.Create(applicationManifest,
_authentication, UserActivationMode.Permanent);
// If not using the current Windows user, use
// UserActivationMode.Temporary to display the Windows
// credentials pop-up window.
///_secureEnv = SecureEnvironment.Create(applicationManifest,
/// a_authentication, UserActivationMode.Temporary);
}
ShowStatus(" Created SecureEnvironment for user:\n " +
_secureEnv.User.Name +
" [" + _secureEnv.User.AuthenticationType + "]");
ShowStatus(" Initiating SecureEnvironment as user: " & vbLf & " " & currentUserId & " [" & _authentication & "]")
If SecureEnvironment.IsUserActivated(New ContentUser(currentUserId, _authentication)) Then
ShowStatus(" User is already activated.")
_secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(currentUserId, _authentication))
Else ' if user is not yet activated.
ShowStatus(" User is NOT activated," & vbLf & " activating now....")
' If using the current Windows user, no credentials are
' required and we can use UserActivationMode.Permanent.
_secureEnv = SecureEnvironment.Create(applicationManifest, _authentication, UserActivationMode.Permanent)
' If not using the current Windows user, use
' UserActivationMode.Temporary to display the Windows
' credentials pop-up window.
'''_secureEnv = SecureEnvironment.Create(applicationManifest,
''' a_authentication, UserActivationMode.Temporary)
End If
ShowStatus(" Created SecureEnvironment for user:" & vbLf & " " & _secureEnv.User.Name & " [" & _secureEnv.User.AuthenticationType & "]")