Subscribe to Windows IT Pro
May 25, 2004 12:00 AM

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

Windows IT Pro
InstantDoc ID #80951
Rating: (1)


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
setlocal
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
:finish
endlocal&set %2=%desc%



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.