{"id":5530,"date":"2019-08-29T21:45:30","date_gmt":"2019-08-30T02:45:30","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=5530"},"modified":"2021-03-17T23:22:41","modified_gmt":"2021-03-18T04:22:41","slug":"finding-disabled-accounts-in-active-directory","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=5530","title":{"rendered":"Finding Disabled Accounts In Active Directory"},"content":{"rendered":"<p>When using Active Directory (AD) as a source of user data, it&#8217;s useful to filter out <em>disabled<\/em> accounts. Unfortunately, AD has a lot of different security-related settings glomed together in the userAccountControl attribute. Which means there&#8217;s no single attribute\/value combination you can use to ignore disabled accounts.<\/p>\n<p>The decimal value you see for userAccountControl isn&#8217;t terribly useful, but display it in binary and each bit position has a meaning. The userAccountControl value is just the number with a bunch of bits set. Numbering the bits from left to right, here is what each one means.<\/p>\n<table width=\"492\">\n<tbody>\n<tr>\n<td width=\"121\">Bit #<\/td>\n<td width=\"371\">Meaning<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">0<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">1<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">2<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">3<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">4<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">5<\/td>\n<td>ADS_UF_PARTIAL_SECRETS_ACCOUNT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">6<\/td>\n<td>ADS_UF_NO_AUTH_DATA_REQUIRED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">7<\/td>\n<td>ADS_UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">8<\/td>\n<td>ADS_UF_PASSWORD_EXPIRED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">9<\/td>\n<td>ADS_UF_DONT_REQUIRE_PREAUTH<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">10<\/td>\n<td>ADS_UF_USE_DES_KEY_ONLY<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">11<\/td>\n<td>ADS_UF_NOT_DELEGATED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">12<\/td>\n<td>ADS_UF_TRUSTED_FOR_DELEGATION<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">13<\/td>\n<td>ADS_UF_SMARTCARD_REQUIRED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">14<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">15<\/td>\n<td>ADS_UF_DONT_EXPIRE_PASSWD<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">16<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">17<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">18<\/td>\n<td>ADS_UF_SERVER_TRUST_ACCOUNT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">19<\/td>\n<td>ADS_UF_WORKSTATION_TRUST_ACCOUNT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">20<\/td>\n<td>ADS_UF_INTERDOMAIN_TRUST_ACCOUNT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">21<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">22<\/td>\n<td>ADS_UF_NORMAL_ACCOUNT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">23<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">24<\/td>\n<td>ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">25<\/td>\n<td>ADS_UF_PASSWD_CANT_CHANGE<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">26<\/td>\n<td>ADS_UF_PASSWD_NOTREQD<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">27<\/td>\n<td>ADS_UF_LOCKOUT<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">28<\/td>\n<td>ADS_UF_HOMEDIR_REQUIRED<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">29<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">30<\/td>\n<td>ADS_UF_ACCOUNT_DISABLE<\/td>\n<\/tr>\n<tr>\n<td width=\"121\">31<\/td>\n<td>Unused &#8211; must be 0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Bit #30 indicates if the account is disabled &#8212; 1 if the account is disabled, 0 if the account is enabled. Simple and direct approach is to &#8220;and&#8221; the attribute value with 0b10 to extract <em>just<\/em> the bit we care about. When the and operation returns 0, the account is enabled. When it returns 2 (0x10), the account is disabled.<\/p>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=5531\" rel=\"attachment wp-att-5531\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5531\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/09\/ExtractingSingleBit.png\" alt=\"\" width=\"658\" height=\"203\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/09\/ExtractingSingleBit.png 658w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2019\/09\/ExtractingSingleBit-300x93.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/a><\/p>\n<p>A list of userAccountControl values and the corresponding meaning:<\/p>\n<table width=\"752\">\n<tbody>\n<tr>\n<td width=\"172\">userAccountControl Value<\/td>\n<td width=\"580\">Meaning<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">1<\/td>\n<td width=\"580\">Logon script executes<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">2<\/td>\n<td width=\"580\">Account Disabled<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">8<\/td>\n<td width=\"580\">Home Directory Required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">16<\/td>\n<td width=\"580\">Lockout<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">32<\/td>\n<td width=\"580\">Password Not Required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">64<\/td>\n<td width=\"580\">User cannot change password<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">128<\/td>\n<td width=\"580\">Encrypted text password not allowed<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">256<\/td>\n<td width=\"580\">Temporary Duplicate Account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">512<\/td>\n<td width=\"580\">Normal active account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">514<\/td>\n<td width=\"580\">Normal disabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">544<\/td>\n<td width=\"580\">Password not required, enabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">546<\/td>\n<td width=\"580\">Password not required, disabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">2048<\/td>\n<td width=\"580\">Inter-domain trust account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">4096<\/td>\n<td width=\"580\">Workstation trust account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">8192<\/td>\n<td width=\"580\">Server trust account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">65536<\/td>\n<td width=\"580\">No password expiry<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">66048<\/td>\n<td width=\"580\">Password never expires, enabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">66050<\/td>\n<td width=\"580\">Password never expires, disabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">66082<\/td>\n<td width=\"580\">Password never expires and is not required, enabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">66084<\/td>\n<td width=\"580\">Password never expires and is not required, disabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">131072<\/td>\n<td width=\"580\">MNS Login account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">262144<\/td>\n<td width=\"580\">Smartcard required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">262656<\/td>\n<td width=\"580\">Smartcard required, enabled account<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">262658<\/td>\n<td width=\"580\">Smartcard required, disabled account<\/td>\n<\/tr>\n<tr>\n<td>262688<\/td>\n<td width=\"580\">Enabled account, password not required, smartcard required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">262690<\/td>\n<td width=\"580\">Disabled account, password not required, smartcard required<\/td>\n<\/tr>\n<tr>\n<td>328192<\/td>\n<td width=\"580\">Enabled account, password doesn&#8217;t expire, smartcard required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">328194<\/td>\n<td width=\"580\">Disabled account, password doesn&#8217;t expire, smartcard required<\/td>\n<\/tr>\n<tr>\n<td>328224<\/td>\n<td width=\"580\">Enabled account, password doesn&#8217;t expire, password not required, smartcard required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">328226<\/td>\n<td width=\"580\">Disabled account, password doesn&#8217;t expire, password not required, smartcard required<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">524288<\/td>\n<td width=\"580\">Trusted for delegation<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">532480<\/td>\n<td width=\"580\">Domain controller<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">1048576<\/td>\n<td width=\"580\">Not delegated<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">2097152<\/td>\n<td width=\"580\">Use DES key only<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">4194304<\/td>\n<td width=\"580\">Don&#8217;t require pre-authorization<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">8388608<\/td>\n<td width=\"580\">Password expired<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">16777216<\/td>\n<td width=\"580\">Trusted to auth for delegation<\/td>\n<\/tr>\n<tr>\n<td width=\"172\">67108864<\/td>\n<td width=\"580\">Partial secrets account<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using Active Directory (AD) as a source of user data, it&#8217;s useful to filter out disabled accounts. Unfortunately, AD has a lot of different security-related settings glomed together in the userAccountControl attribute. Which means there&#8217;s no single attribute\/value combination you can use to ignore disabled accounts. The decimal value you see for userAccountControl isn&#8217;t &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[68,814],"class_list":["post-5530","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-active-directory","tag-useraccountcontrol"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5530"}],"version-history":[{"count":3,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5530\/revisions"}],"predecessor-version":[{"id":7564,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/5530\/revisions\/7564"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}