JSI Tip 9856. How can I decode the grouptype attribute?

Jerold Schulman

October 27, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I have scripted EnumGroupType.bat to return the group scope and group type.

The syntax for using EnumGroupType.bat is:

call EnumGroupType GroupType Scope SecDst

Where:

GroupType is the GroupType attribute of a group.Scope     is a call directed environment variable that will contain:                          B   for a Built-in group.                          L   for a Domain Local group.                          G   for a Global group.                          U   for a Universal group.SecDst   is a call directed environment variable that will contain:                          S   for a security group.                          D   for a distribution group.

EnumGroupType.bat contains:

@echo offif {%3}=={} @echo Syntax: EnumGroupType GroupType Scope SecDst&goto :EOFsetlocalif exist "TEMP%EnumGroupType.vbs" goto [email protected] objArgs, gt>"%TEMP%EnumGroupType.vbs"@echo.Set objArgs = Wscript.Arguments>>"%TEMP%EnumGroupType.vbs"@echo.gt = objArgs(0)>>"%TEMP%EnumGroupType.vbs"@echo.if (gt ANd ^&h01) ^ 0 then>>"%TEMP%EnumGroupType.vbs"@echo. Scope = "B">>"%TEMP%EnumGroupType.vbs"@echo.ElseIf (gt And ^&h02) ^ 0 Then>>"%TEMP%EnumGroupType.vbs"@echo. Scope = "G">>"%TEMP%EnumGroupType.vbs"@echo.ElseIf (gt And ^&h04) ^ 0 Then>>"%TEMP%EnumGroupType.vbs"@echo. Scope = "L">>"%TEMP%EnumGroupType.vbs"@echo.ElseIf (gt And ^&h08) ^ 0 Then>>"%TEMP%EnumGroupType.vbs"@echo. Scope = "U">>"%TEMP%EnumGroupType.vbs"@echo.End If>>"%TEMP%EnumGroupType.vbs"@echo.If (gt And ^&h80000000) ^ 0 Then>>"%TEMP%EnumGroupType.vbs"@echo. SecDst = "S">>"%TEMP%EnumGroupType.vbs"@echo.Else>>"%TEMP%EnumGroupType.vbs"@echo. SecDst = "D">>"%TEMP%EnumGroupType.vbs"@echo.End If>>"%TEMP%EnumGroupType.vbs"@echo.Wscript.Echo Scope ^& " " ^& SecDst>>"%TEMP%EnumGroupType.vbs":startfor /f "Tokens=1,2" %%x in ('cscript //nologo "%TEMP%EnumGroupType.vbs" %1') do ( set s1=%%x set s2=%%y)endlocal&set %2=%s1%&set %3=%s2%



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like