see user and membership

M

Matte

Hello.

Anyone know if its possible to get the membership/group that a user belongs
to in a logon script?

Thanks in advance
 
J

Jerold Schulman

Hello.

Anyone know if its possible to get the membership/group that a user belongs
to in a logon script?

Thanks in advance
setlocal enabledelayedexpansion
for /f "Tokens=1-3 Delims=*" %%a in ('net user %username% /domain^|Find " *"') do (
set g1=%%a
set g2=%%b
set g3=%%c
...
....
....
)


or

Use ADFind.exe, tip 5898 » Freeware ADFind.
in the 'Tips & Tricks' at http://www.jsifaq.com

Place Adfind.exe in the Netlogon share of all DCs.

@echo off
setlocal
for /f "Tokens=*" %%g in ('%LOGONSERVER%\NETLOGON\adfind.exe -nodn -csv -nocsvheader -default -f "&(objectcategory=person)(objectClass=user)(sAMAccountName=%UserName%)" memberOf') do (
if %%g NEQ "" call :groups %%g
)
endlocal
goto :EOF
:groups
set gline=%1
set gline=%gline:"=%
....
....
....

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
J

Joe Richards [MVP]

In additional to what Jerry indicated, you can also look at the memberof tool on
my website as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top