Executive Summary: Providing local print services for mobile users can be problematic in small-to-midsized businesses (SMBs) with multiple sites. Out-of-the-box solutions often don't work, and creating a scripted solution can be difficult. Fortunately, Alex K. Angelopoulos has come up with a generic scripted solution you can use. All you need to do is follow seven simple steps to customize and implement the solution. Afterward, your mobile users will automatically have site-specific printers mapped and available when the log on. |
Providing local print services for mobile users can be a perpetual problem in small-to-midsized businesses (SMBs) with multiple sites. Currently, there is no out-of-box solution for providing location-based print services to mobile users for OSs earlier than Windows Vista. Starting in Vista, Microsoft offers an out-of-the-box solution for location-based printer assignment, but it isn't very useful for SMBs for two reasons. First, the assignment policies require an Active Directory (AD) structure that accurately reflects WAN topology. Second, the assignment policies take effect only after a Group Policy refresh.
It's possible to solve this kind of problem with a script; it just takes some scripting skills and some time, which is often in short supply in a hectic network. The central problem is figuring out where a user is at when they log on to a network. The most reliable technique for determining a user's location is to get the network ID for the local system, then match that address to a known location. Although you can summarize the solution very simply as "if a computer is on network X, map printer group Y," scripting that solution is far from simple.
First, you need to get the network ID for the local system. You can obtain the information needed to calculate this ID from Windows Management Instrumentation's (WMI's) Win32_NetworkAdapterConfiguration class. However, you need to get the values of two properties—IPAddress (which contains IP addresses) and IPSubnet (which contains subnet masks)—then perform a bitwise AND operation on those values to get the network ID. To further complicate matters, computers generally have several different network interfaces, so IPAddress and IPSubnet are arrays that typically contain multiple IP addresses and subnet masks, respectively. Even when there's only one IP address or one subnet mask, you still need to loop through the property to extract it because WMI will return that IP address or subnet mask as an array.
Problem: In SMBs with multiple sites, there's no simple automated way to map printers for mobile users.
Solution: Customize AddressBasedPrinter.vbs, then use with a network logon script to automatically create site-specific printer mappings when mobile users log on.
What You Need: AddressBasedPrinter.vbs, logon script, Notepad (or another text editor)
Solution Steps: 1. Pick site the names. 2. Download and open AddressBasedPrinter.vbs. 3. Customize the code in callout B. 4. Customize the code in callout D. 5. Test AddressBasedPrinter.vbs. 6. Integrate with existing network logon scripts. 7. Update AddressBasedPrinter.vbs as needed.
Difficulty: 3 out of 5 |
If you're lucky, you'll only have one network ID at this point. However, in all likelihood, you'll have several network IDs, with no direct way to determine which one is used for the LAN connection. To determine the correct one, you need to compare the network ID for the local computer to the network IDs for each site until you find a match.
Once a match is found, you aren't completely done. It's possible that the mobile user is running a Terminal Server session. You don't want to map printers for a Terminal Services session because printers located near the Terminal Server are by definition almost certain to be far away from the user. So, you need to account for this situation.
Finally, you need to handle two other possibilities. You need to handle situations in which there are multiple matches and no matches.