Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


Windows Server Hacks

Windows Server Hacks: Creating a Shortcut for Searching Active Directory

by Mitch Tulloch, author of Windows Server Hacks
06/01/2004

Active Directory lets administrators publish information about shared folders, printers, and other resources on their networks. Having users actually find this information is another thing, though. User education is part of the solution, and IT departments should work closely with management to ensure adequate budget allotments for end-user training. But with this simple hack, administrators can also make searching Active Directory easier for users.

First, let's see how users normally find things in Active Directory. On a Windows XP desktop machine, a user can search Active Directory for a shared printer using the Search Companion by selecting Start --> Search:

Figure 1

To search for shared printers, click the "Printers, computers, or people" link at the left. The Search Companion then asks, "What are you looking for?" and you click "A printer on the network" to open the Find Printers dialog:

Figure 2

Type the name, location, or model number to find the printer you are looking for. For example, say I'm looking for a printer on the 2nd floor:

Figure 3

I can now install the printer by right-clicking on it and selecting Connect from the shortcut menu. The printer should now appear in my Printers and Faxes folder. Cool.

Searching for shared folders is a little less intuitive, however. First the user has to open My Network Places, and if an icon for this isn't present on the desktop one can be displayed by choosing Control Panel --> Display --> Desktop --> Customize Desktop --> General --> select My Network Places. Once My Network Places is open, it looks like this:

Figure 4

Note the Search Active Directory link on the left, under Network Tasks. Clicking this link displays the Find Users, Contacts, and Groups dialog:

Figure 5

In the Find dropdown list box select Shared Folders, and type the name of the shared folder you are looking for, or any keywords that were assigned to it after it was published in Active Directory:

Figure 6

Then click Find Now to find a list of possible shares:

Figure 7

Now simply double-click on the share you want and access the files it contains.

That's a lot for users to remember, isn't it? Here's a simpler alternative: Create a shortcut on their desktops with the following path:

%windir%\system32\rundll32.exe dsquery.dll,OpenQueryWindow

Name the new shortcut something like Search Active Directory and you're done. Users can now open the Find Users, Contacts, and Groups dialog by simply double-clicking on this shortcut, making it easier for them to find shared folders and other resources in Active Directory. Nice.

Windows Server Hacks

Related Reading

Windows Server Hacks
100 Industrial-Strength Tips & Tools
By Mitch Tulloch

Hacking the Hack

If you're just planning your deployment of desktop machines, you can automate the above procedure by copying the shortcut to the Desktop subfolder of the Default User Profile you plan to base your users' profiles on. To learn how to create such a base profile see Knowledge Base article 168475 on Microsoft's web site.

If your desktops are already deployed however, you can create a logon script that contains the following command, which copies a shortcut named SearchAD.lnk to the Desktop folder of users' profiles when they next log on to their systems:

@copy \\servername\sharename\SearchAD.lnk "%UserProfile%\Desktop\SearchAD.lnk"

Then save this file as logon.bat and assign it using Group Policy to deploy the shortcut. By the way, note the double quotes around the destination path -- these are required since %UserProfile% is replaced by the string "Documents and Settings" before the copy command executes, and "Documents and Settings" has spaces in it.

Mitch Tulloch is the author of Windows 2000 Administration in a Nutshell, Windows Server 2003 in a Nutshell, and Windows Server Hacks.


Return to WindowsDevCenter.com.

Copyright © 2009 O'Reilly Media, Inc.