Language

UserPrincipal コンストラクター

定義

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

オーバーロード

Name 説明
UserPrincipal(PrincipalContext)

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

UserPrincipal(PrincipalContext, String, String, Boolean)

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

UserPrincipal(PrincipalContext)

ソース:
User.cs
ソース:
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
ソース:
User.cs

指定したコンテキスト、SAM アカウント名、パスワード、および有効な値を使用して、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 メソッドを呼び出します。

適用対象