Solved

AD or LDAP query needed.....

Posted on 2004-08-31
3
248 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 83

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
A procedure for exporting installed hotfix details of remote computers using powershell
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now