JSI Tip 8072. How can I decode the sAMAccountType attribute?

When you user the DSQUERY command to return the sAMAccountType attribute, it is returned as a numeric value.

I have scripted sAMAccountType.bat to translate this value.

The syntax for using sAMAccountType.bat is:

call sAMAccountType sat satDescription

Where sat is the numeric value of the sAMAccountType attribute, and satDescription is a call directed environment variable that will contain the description of the object.

sAMAccountType.bat contains:

@echo off
if \{%2\}==\{\} @echo Syntax: call sAMAccountType sat satDescription&goto :EOF
if "%1" EQU "0" set %2=SAM_DOMAIN_OBJECT&goto :EOF
set /a sat=%1
set desc=UNKNOWN
if %sat% EQU 268435456 set desc=SAM_GROUP_OBJECT&goto finish
if %sat% EQU 268435457 set desc=SAM_NON_SECURITY_GROUP_OBJECT&goto finish
if %sat% EQU 536870912 set desc=SAM_ALIAS_OBJECT&goto finish
if %sat% EQU 536870913 set desc=SAM_NON_SECURITY_ALIAS_OBJECT&goto finish
if %sat% EQU 805306368 set desc=SAM_NORMAL_USER_ACCOUNT&goto finish
if %sat% EQU 805306369 set desc=SAM_MACHINE_ACCOUNT&goto finish
if %sat% EQU 805306370 set desc=SAM_TRUST_ACCOUNT&goto finish
if %sat% EQU 1073741824 set desc=SAM_APP_BASIC_GROUP&goto finish
if %sat% EQU 1073741825 set desc=SAM_APP_QUERY_GROUP&goto finish
if %sat% EQU 2147483647 set desc=SAM_ACCOUNT_TYPE_MAX
endlocal&set %2=%desc%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.