madhatter22 / LinqToLdap

C# LINQ provider built on top of System.DirectoryServices.Protocols for querying and updating LDAP servers.
MIT License
45 stars 23 forks source link

Easy way to read UserAccountControl flags #42

Open rklec opened 1 month ago

rklec commented 1 month ago

It wold be great, if there was an easy way to read UserAccountControl. I know you probably can read them as an int and convert them with the magic numbers etc. However, that requires me to maintain custom logic for that, which could be implemented in a library like this.

https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/useraccountcontrol-manipulate-account-properties

E.g. like this to define a start for the most common ones:

/**
 * <summary><see href="https://learn.microsoft.com/en-us/troubleshoot/windows-server/active-directory/useraccountcontrol-manipulate-account-properties"/></summary>
 */
[Flags]
public enum UserAccountControlFlags
{
    ACCOUNTDISABLE = 2,
    LOCKOUT = 16,
    PASSWORD_EXPIRED = 0x800000
}

Or see https://stackoverflow.com/questions/10231914/useraccountcontrol-in-active-directory?rq=3