Share via


UserPrincipal コンストラクター

定義

UserPrincipal クラスの新しいインスタンスを初期化します。

オーバーロード

UserPrincipal(PrincipalContext)

指定されたコンテキストを使用して、UserPrincipal クラスの新しいインスタンスを初期化します。

UserPrincipal(PrincipalContext, String, String, Boolean)

指定したコンテキスト、SAM アカウント名、パスワード、および enabled 値を使用して、UserPrincipal クラスの新しいインスタンスを初期化します。

UserPrincipal(PrincipalContext)

ソース:
User.cs
ソース:
User.cs
ソース:
User.cs

指定されたコンテキストを使用して、UserPrincipal クラスの新しいインスタンスを初期化します。

public:
 UserPrincipal(System::DirectoryServices::AccountManagement::PrincipalContext ^ context);
public UserPrincipal (System.DirectoryServices.AccountManagement.PrincipalContext context);
new System.DirectoryServices.AccountManagement.UserPrincipal : System.DirectoryServices.AccountManagement.PrincipalContext -> System.DirectoryServices.AccountManagement.UserPrincipal
Public Sub New (context As PrincipalContext)

パラメーター

context
PrincipalContext

操作が実行されるサーバーまたはドメインを指定する PrincipalContext

次のコード例では、コンストラクターで PrincipalContext 初期化されたユーザー名とパスワードを使用して LDAP ドメイン "fabrikam.com" に "administrator" と "securelyStoredPassword" に接続します。

この例で設定されたプロパティ (ユーザー名や電子メール アドレスなど) は、コンストラクターで指定されたコンテナーの下に PrincipalContext 作成されます:"CN=Users,DC=fabrikam,DC=com"

PrincipalContext ctx = new PrincipalContext(  
                                         ContextType.Domain,  
                                         "fabrikam.com",   
                                         "CN=Users,DC=fabrikam,DC=com",  
                                         "administrator",   
                                         "securelyStoredPassword");   

UserPrincipal usr = new UserPrincipal(ctx);  

usr.Name = "Jim Daly";  
usr.Description = "This is the user account for Jim Daly";  
usr.EmailAddress = "jimdaly@fabrikam.com";  
usr.SetPassword("securelyStoredPassword");  
usr.Save();  

usr.Dispose();  
ctx.Dispose();   

注釈

ユーザー プリンシパル アカウントは、作成時に保持されません。 アカウントを保存するには、 メソッドを呼び出します Save

適用対象

UserPrincipal(PrincipalContext, String, String, Boolean)

ソース:
User.cs
ソース:
User.cs
ソース:
User.cs

指定したコンテキスト、SAM アカウント名、パスワード、および enabled 値を使用して、UserPrincipal クラスの新しいインスタンスを初期化します。

public:
 UserPrincipal(System::DirectoryServices::AccountManagement::PrincipalContext ^ context, System::String ^ samAccountName, System::String ^ password, bool enabled);
public UserPrincipal (System.DirectoryServices.AccountManagement.PrincipalContext context, string samAccountName, string password, bool enabled);
new System.DirectoryServices.AccountManagement.UserPrincipal : System.DirectoryServices.AccountManagement.PrincipalContext * string * string * bool -> System.DirectoryServices.AccountManagement.UserPrincipal
Public Sub New (context As PrincipalContext, samAccountName As String, password As String, enabled As Boolean)

パラメーター

context
PrincipalContext

操作が実行されるサーバーまたはドメインを指定する PrincipalContext

samAccountName
String

このユーザー プリンシパルの SAM アカウント名。

password
String

このアカウントのパスワード。

enabled
Boolean

アカウントが有効かどうかを示すブール値。

注釈

ユーザー プリンシパル アカウントは、作成時に保持されません。 アカウントを保存するには、 メソッドを呼び出します Save

適用対象