Decode User Account Control
Decodes the UserAccountControl (UAC) flags for an Active Directory user account and returns a readable list of the active flags.
- Iterates through all known UAC flag values defined in Active Directory and checks which ones are active in the provided uac.
- Flags with multiple matches are concatenated in the result for a comprehensive overview.
- Useful for troubleshooting or auditing user account configurations.
VB
Function DecodeUserAccountControl(uac As Integer) As String
Dim flags As New List(Of String)
Dim uacFlags As New Dictionary(Of Integer, String) From {
{1, "Logon script required"},
{2, "Account is disabled"},
{8, "Home directory required"},
{16, "Account is locked out"},
{32, "Password not required"},
{64, "Password can't be changed (handled elsewhere)"},
{128, "Encrypted text password allowed"},
{256, "Temporary duplicate account"},
{512, "Normal user account"},
{1024, "Interdomain trust account"},
{2048, "Workstation trust account"},
{4096, "Server trust account"},
{8192, "Password does not expire"},
{16384, "MNS logon account"},
{65536, "Password does not expire"},
{131072, "Smartcard required"},
{262144, "Trusted for delegation"},
{524288, "Not trusted for delegation"},
{1048576, "Use DES encryption only"},
{2097152, "Do not require Kerberos preauthentication"},
{4194304, "Password is expired"},
{8388608, "Trusted to authenticate for delegation"},
{16777216, "Partial secrets account"}
}
For Each kvp In uacFlags
If (uac And kvp.Key) = kvp.Key Then
flags.Add(kvp.Value)
End If
Next
Return String.Join(", ", flags)
End Function