Solved

AD or LDAP query needed.....

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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…
When you’re making plans to join the modern business race, you should analyze various details that may affect your results. Nowadays, millions of businesses are trying to grow into established and appreciated professional enterprises.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

815 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

8 Experts available now in Live!

Get 1:1 Help Now