Home > Articles > Operating Systems, Server > Microsoft Servers

📄 Contents

  1. Configuring Samba
  2. Creating Login Scripts to Map Samba Shares
  3. Conclusion
  • Print
  • + Share This
Like this article? We recommend

Creating Login Scripts to Map Samba Shares

To continue with the example, I'll give Ted a logon script that will map the Samba Accounting share to his account. To create a logon script, open up any text editor and use the following syntax to map a drive.

net use <drive letter>: \\<path> /<switches, if any>

The net use command is a Windows command used to map drives. If LinShare is my Samba server's hostname, I would type the following to map the Accounting share for Ted:

net use Z: \\LinShare\Accounting 

I could also use LinShare's IP address instead of the hostname. In this example, I use the drive letter Z to map the Accounting share. Now I need to save the script as a batch file. To do this, I simply give it a name with the .bat file extension. I'm going to name this script ted.bat and save it to the Windows SysVol logon share. The SysVol share is where Windows Server stores logon scripts. The scripts must be placed here because this is where the server looks when executing a logon script. The path to the SysVol share on a Windows 2003 server is as follows:

C:\WINDOWS\SYSVOL\sysvol\<machine_name.domain_name>\scripts

After the script has been created and saved to this directory, we can now map the script to a user account. Open the Active Directory Users and Computers snap-in on your domain controller by clicking Start and selecting Run. In the Run dialog box, type dsa.msc and click OK. The console will appear and open the Users folder by default, showing all your users in the right pane. To map the script, double-click a user and select the Profile tab, as shown in Figure 1.

Figure 1Figure 1 Adding a user logon script.

In the Logon Script text box, type the name of the logon script (Ted in this example). There is no need to put the file extension because the server defaults logon scripts to the .bat extension. If you had a different logon script file type, such as .vbs, you would need to add the extension to the filename. Click OK and you're done.

When Ted logs in from now on, the Samba Accounting share will appear in his drive list as drive Z. What's slick about this is that Ted needs to log in only once; the share is automatically mapped to his account based on his domain credentials. Because the Samba credentials are the same, no other login is necessary. Samba knows he is a valid user. He can access the drive just like any other. He can also log in from any workstation on the network, and the drive is mapped to that machine by the login script every time while he is logged-in.

  • + Share This
  • 🔖 Save To Your Account