Solved

AD or LDAP query needed.....

Posted on 2004-08-31
3
252 Views
Last Modified: 2010-04-13
I'd like to query Active Directory and I believe I would have to use an LDAP query for this one.

I'd like to return a list of usernames with the logon script defined in their profile.
I can't seem to find anything regarding the logon script in the advanced filter in AD U/C.

Any help is greatly appreciated.

Matthewe Jones
matthewjones@comcast.net
0
Comment
Question by:matthewjones
3 Comments
 
LVL 9

Expert Comment

by:BigC666
ID: 11944722
howdy,

have a look at this  http://www.microsoft.com/technet/scriptcenter/solutions/spnquery.mspx

hope that it helps
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 11945413
That should give you a list of your users and the according logon scripts. If you have the W2k Resource Kit (in particular global.exe), this could be simplified a bit; most of the script handles the unbearable "net user" output ...

====8<----[LogonScripts.cmd]----
@echo off
setlocal
set TempFile=%~dpn0.tmp

if exist "%TempFile%" del "%TempFile%"
:: *** The number of the first useless lines of the 'net group "domain users" /domain' command output:
set NetFirst=4
:: *** The last line of the 'net user /domain' command output:
set NetLast=The command completed successfully

for /f "skip=%NetFirst% delims=" %%a in ('net user /domain') do (
 set Line=%%a
 call :UserList
)
for /f %%a in ('type "%TempFile%"') do (
  for /f "tokens=2*" %%i in ('net user %%a /domain ^| find /i "Logon script"') do echo %%a,%%j
)
goto leave

:UserList
:: *** Get the accounts, configured in three columns:
set Account1=%Line:~0,25%
set Account2=%Line:~25,25%
set Account3=%Line:~50,25%
:: *** Avoid processing the "The command completed successfully" line
if /i "%Account1%"=="%NetLast:~0,25%" goto :eof
:: *** Remove spaces
if not "%Account1%"=="" set Account1=%Account1: =%
if not "%Account2%"=="" set Account2=%Account2: =%
if not "%Account3%"=="" set Account3=%Account3: =%
if "%Account1%"=="" goto :eof
>>"%TempFile%" echo %Account1%
if "%Account2%"=="" goto :eof
>>"%TempFile%" echo %Account2%
if "%Account3%"=="" goto :eof
>>"%TempFile%" echo %Account3%
goto :eof

:leave
del "%TempFile%"
====8<----[LogonScripts.cmd]----
0
 
LVL 1

Author Comment

by:matthewjones
ID: 11945813
oBdA gave a quick and right on answer + a script I can learn from.

Thank you both for the fast answer and knoweldge..

Matthew Jones
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question