UserAccountControlFlags userAccFlags = (UserAccountControlFlags) 66050;
// Much more readable
if(userAccFlags.Has(UserAccountControlFlags.AccountDisabled))
{
// Do your stuff here
}
そして、ここに拡張メソッドがあります:
public static bool Has<T>(this System.Enum type, T value) where T : struct
{
return ((int)(object)type & (int)(object)value) > 0;
}
C# Onlineから参照される列挙型定義
[Flags]
public enum UserAccountControlFlags
{
Script = 0x1,
AccountDisabled = 0x2,
HomeDirectoryRequired = 0x8,
AccountLockedOut = 0x10,
PasswordNotRequired = 0x20,
PasswordCannotChange = 0x40,
EncryptedTextPasswordAllowed = 0x80,
TempDuplicateAccount = 0x100,
NormalAccount = 0x200,
InterDomainTrustAccount = 0x800,
WorkstationTrustAccount = 0x1000,
ServerTrustAccount = 0x2000,
PasswordDoesNotExpire = 0x10000,
MnsLogonAccount = 0x20000,
SmartCardRequired = 0x40000,
TrustedForDelegation = 0x80000,
AccountNotDelegated = 0x100000,
UseDesKeyOnly = 0x200000,
DontRequirePreauth = 0x400000,
PasswordExpired = 0x800000,
TrustedToAuthenticateForDelegation = 0x1000000,
NoAuthDataRequired = 0x2000000
}