Solved

AD or LDAP query needed.....

Posted on 2004-08-31
3
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Title # Comments Views Activity
Syteline and a new domain controller 4 749
Remote Access to a Windows 2000 Computer 2 518
Migrate Windows NT to Windows 2003 2 533
Active Directory Replication 10 1,153
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…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

737 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