次の方法で共有


ユーザー アカウント フラグの設定

このトピックでは、さまざまなユーザー フラグを設定するコード例を示します。この例では、DirectoryEntry オブジェクトの Properties プロパティを使用して、User-Account-Control 属性にアクセスし、ADS_USER_FLAG_ENUM 列挙体で定義されているフラグを設定します。User-Account-Control 属性の詳細については、MSDN ライブラリ (https://go.microsoft.com/fwlink/?LinkID=27252) で User-Account-Control に関するページを参照してください。ADS_USER_FLAG_ENUM 列挙体の詳細については、MSDN ライブラリ (https://go.microsoft.com/fwlink/?LinkID=27252) で ADS_USER_FLAG_ENUM に関するページを参照してください。

次の例は、DirectoryEntry オブジェクト usr のさまざまなプロパティの設定方法を示しています。このコードは、System.DirectoryServices 名前空間のオブジェクトにアクセスするので、このコードをアプリケーション内で使用する場合は、ソリューション エクスプローラで System.DirectoryServices 名前空間への参照を追加してください。

次の例は、対話型ログオンにスマート カードの使用を要求する方法を示しています。

[Visual Basic]

Const ADS_UF_SMARTCARD_REQUIRED As Integer = &H40000
Val = Fix(usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or _
      ADS_UF_SMARTCARD_REQUIRED
usr.CommitChanges()
const int ADS_UF_SMARTCARD_REQUIRED = 0x40000;
val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    ADS_UF_SMARTCARD_REQUIRED;
usr.CommitChanges();

次の例は、DES 暗号化を使用するようにアカウントを設定する方法を示しています。

[Visual Basic]

Const ADS_UF_USE_DES_KEY_ONLY As Integer = &H200000
Val = Fix(usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or _
      ADS_UF_USE_DES_KEY_ONLY
usr.CommitChanges()
const int ADS_UF_USE_DES_KEY_ONLY=0x200000;
val= (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    ADS_UF_USE_DES_KEY_ONLY;
usr.CommitChanges();

次の例は、委任先として信頼できるようにアカウントを設定する方法を示しています。

[Visual Basic]

Const ADS_UF_TRUSTED_FOR_DELEGATION As Integer = &H80000
Val = Fix(usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or _
      ADS_UF_TRUSTED_FOR_DELEGATION
usr.CommitChanges()
const int ADS_UF_TRUSTED_FOR_DELEGATION =0x80000;
val= (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    ADS_UF_TRUSTED_FOR_DELEGATION;
usr.CommitChanges();

次の例は、アカウントが機密であり、委任先として使用できないことを表す方法を示しています。

[Visual Basic]

Const ADS_UF_NOT_DELEGATED As Integer = &H100000
Val = Fix(usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or _
      ADS_UF_NOT_DELEGATED
usr.CommitChanges()
const int ADS_UF_NOT_DELEGATED=0x100000;
val= (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    ADS_UF_NOT_DELEGATED;
usr.CommitChanges();

次のコード例は、Kerberos 事前認証を必要としないようにアカウントを設定する方法を示しています。

[Visual Basic]

Const ADS_UF_DONT_REQUIRE_PREAUTH As Integer = &H400000
Val = Fix(usr.Properties("userAccountControl").Value)
usr.Properties("userAccountControl").Value = val Or _
      ADS_UF_DONT_REQUIRE_PREAUTH
usr.CommitChanges()
const int ADS_UF_DONT_REQUIRE_PREAUTH=0x400000;
val= (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val | 
    ADS_UF_DONT_REQUIRE_PREAUTH;
usr.CommitChanges();

関連項目

リファレンス

System.DirectoryServices
DirectoryEntry

概念

ユーザー管理

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.