@echo off if defined _vect_ goto :%_vect_% setlocal set _this_="%~f0" set _esep_=============================================================================== set _vect_=GetDefaultSettings call %_this_% set _vect_=EchoSettings call %_this_% echo. set _resp_= set /p _resp_=Enter 'y' to change these settings: if "%_resp_%" equ "" goto :Perform if /i "%_resp_:~0,1%" neq "y" goto :Perform set _vect_=GetDomainName call %_this_% set _vect_=CrackDomainName call %_this_% set _vect_=GetDCName call %_this_% set _vect_=GetUserName call %_this_% set _vect_=EchoSettings call %_this_% set _vect_=DumpOnePartition call %_this_% "%_from_%" Configuration call %_this_% "%_from_%" goto :Exit :DumpOnePartition echo. echo %_esep_% set _root_=%~1 if "%~2" equ "" ( set _file_=RootDSE.ldf goto :DumpOnePartitionExecute ) shift set _file_=%~1.ldf :DumpOnePartitionNextSubtree if "%~1" equ "" goto :DumpOnePartitionExecute set _root_=CN=%~1,%_root_% shift goto :DumpOnePartitionNextSubtree :DumpOnePartitionExecute echo Exporting: %USERDNSDOMAIN% echo To: %_file_% echo Root: %_root_% echo. if exist "%_file_%" del /f "%_file_%">nul ldifde.exe %_sarg_%%_uarg_%-d %_root_% -f "%_file_%" set _errn_=%errorlevel% if %_errn_% neq 0 ( echo Error: %_errn_% echo Deleting: %_file_% del /f "%_file_%">nul ) goto :EOF :CrackDomainName set _vect_=CrackDnsDomainName set _from_= for /f "tokens=1-26 delims=." %%a in ("%_ddns_%") do call %_this_% %%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z set _vect_=CrackDomainName goto :EOF :CrackDnsDomainName if "%~1" equ "" goto :EOF if "%_from_%" equ "" ( set _from_=DC=%~1 ) else ( set _from_=%_from_%,DC=%~1 ) shift goto :CrackDnsDomainName :GetDefaultSettings set _ddns_=%USERDNSDOMAIN% set _serv_=%LOGONSERVER:~2% set _user_= set _pass_= set _from_= set _vect_=CrackDomainName call %_this_% %_ddns_% goto :EOF :EchoSettings echo. echo %_esep_% echo Domain: %_ddns_% echo BaseDN: %_from_% if "%_serv_%" equ "" ( echo Server: DC of %_ddns_% ) else ( echo Server: %_serv_% ) if "%_user_%" neq "" ( echo User: %_user_% ) if "%_pass_%" neq "" ( echo Passwd: %_pass_% ) goto :EOF :GetDomainName echo. echo Domain: %_ddns_% echo. set _resp_= set /p _resp_=Enter 'y' to change the domain to bind to: if "%_resp_%" equ "" goto :EOF if /i "%_resp_:~0,1%" neq "y" goto :EOF set _targ_= set /p _targ_=Enter the name of the domain to bind to : if "%_targ_%" equ "" ( set _ddns_=%USERDNSDOMAIN% ) else ( set _ddns_=%_targ_% ) set _vect_=CrackDomainName call %_this_% goto :EOF :GetDCName set _here_=0 if /i "%_serv_%" equ "%COMPUTERNAME%" set _here_=1&set_serv_%=%COMPUTERNAME% echo. if %_here_% equ 0 echo Server: %_serv_% (remote) if %_here_% equ 1 echo Server: %_serv_% echo. set _resp_= set /p _resp_=Enter 'y' to change the server to bind to: if "%_resp_%" equ "" goto :EOF if /i "%_resp_:~0,1%" neq "y" goto :EOF set _targ_= set /p _targ_=Enter the name of the server to bind to : if "%_targ_%" equ "" ( set _serv_= ) else ( set _serv_=%_targ_% ) if "%_serv_%" equ "" ( set _sarg_= ) else ( set _sarg_=-s %_serv_% ) goto :EOF :GetUserName set _user_= echo. echo User: %USERDOMAIN%\%USERNAME% echo. set _resp_= set /p _resp_=Enter 'y' to change the username to bind with: if "%_resp_%" equ "" goto :EOF if /i "%_resp_:~0,1%" neq "y" goto :EOF set _targ_= set /p _targ_=Enter the username to bind with : if "%_targ_%" neq "" ( set _user_=%_targ_% ) if "%_user_%" neq "" ( set _uarg_=-a %_user_% %_ddns_% ) else ( set _uarg_= goto :EOF ) set _targ_= set /p _targ_=Enter the password for %_ddns_%\%_user_% : if "%_targ_%" neq "" ( set _pass_=%_targ_% set _uarg_=%_uarg_%%_targ_% ) goto :EOF :Exit endlocal