UserAccountControlFlags userAccFlags = (UserAccountControlFlags) 66050;
// Much more readable
if(userAccFlags.Has(UserAccountControlFlags.AccountDisabled))
{
// Do your stuff here
}
而這裏的擴展方法:從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
}
所有好的答案,到目前爲止,但由於弗蘭克 - 我想你是第一個! – BIDeveloper 2010-03-16 17:01:04