I would like to know what rights a specific user has in our domain,
specifically what shares this user has rights to.
Using RMTShare.exe from tip 6353 in the 'Tips & Tricks' at
http://www.jsiinc.com
@echo off
if {%2}=={} @echo Syntax: UserSharePerms UserOrGroup ServerName1 [ServerName2 ... ServerNameN]&goto :EOF
setlocal
set UserOrGroup=%1
set UserOrGroup=%UserOrGroup:"=%
:loop
if {%2}=={} goto finish
set server=%2
shift
set server=%server:\=%
for /f "Skip=4 Tokens=*" %%s in ('rmtshare \\%server%') do (
if /i "%%s" NEQ "The command completed successfully." set line=%%s&call

arses
)
goto loop
:finish
endlocal
goto :EOF

arses
set work=%line: =#%
set /a cnt=0
set share=

loop
call set char=%%work:~%cnt%^,1%%
if "%char%" EQU "#" goto getshare
if "%char%" EQU ":" goto fixshare
set share=%share%%char%
set /a cnt=%cnt% + 1
if %cnt% LSS 65 goto ploop
goto :EOF
:fixshare
set /a cnt=%cnt% - 2
call set share=%%share:~0,%cnt%%%
:getshare
set Perm=N
for /f "Skip=3 Tokens=*" %%p in ('rmtshare \\%server%\"%share%"') do (
set line=%%p&call

arsep
)
goto :EOF

arsep
if /i "%line%" EQU "The command completed successfully." goto :EOF
if "%Perm%" EQU "Y" goto parsep1
if /i "%line%" EQU "Permissions:" set Perm=Y
goto :EOF

arsep1
for /f "Tokens=1* Delims=:" %%a in ('@echo %line%') do set who=%%a#&set what=#%%b
set who=%who: #=%
set who=%who:#=%
set OK=N
for /f "Tokens=*" %%u in ('@echo %who%^|FINDSTR /I /L /C:"%UserOrGroup%"') do (
set OK=Y
)
if /i "%OK%" NEQ "Y" goto :EOF
set what=%what:# =%
set what=%what:#=%
@echo "\\%server%\%share%" "%who%" "%what%"
Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com