[Samba] smb.conf for around 2500 users

John Heim jheim at math.wisc.edu
Mon Jul 2 15:55:04 MDT 2012

From: "steve" <steve at steve-ss.com>
To: <samba at lists.samba.org>
Sent: Monday, July 02, 2012 4:09 PM
Subject: Re: [Samba] smb.conf for around 2500 users

> On 02/07/12 21:17, Matthieu Patou wrote:
>> On 07/02/2012 08:39 AM, steve wrote:
>>> Samba4 with Linux and Windows clients wanting to get the same home
>>> folder data.
>>> Hi
>>> A college has students arranged with Linux home directories according
>>> to which year they belong to and which class within that year, a or b
>>> or whatever, they belong to e.g.:
>>> /home2/students/year7/year7a/student1
>>> /home2/students/year7/year7a/student2
>>> ...
>>> ...
>>> /home2/students/year13/year13a/student2500
>>> To get at the same data on windows, I was thinking of a share for each
>>> of the classes e.g.
>>> [year7a]
>>> path = /home2/students/year7/year7a
>>> read only = No
>>> browsable = No
>>> ...
>>> ...
>>> [year13a]
>>> path = /home2/students/year13/year13a
>>> read only = No
>>> browsable = No
>>> and mapping a drive letter to the share e.g.
>>> map Z: to \\server\year7a\%USERNAME%
>>> That would make lots of shares but would make it readable to non admins.
>>> Is there a limit on the number of shares per installation?
>>> Any other ideas of how to go about it? e.g. I thought about OU's but
>>> we do not want to administer from Windows.
>> Did you thought about making a new directory ie.
>> /home2/students/data with a link to each real user and then sharing data
>> like that
>> [data]
>> path = /home2/students/data
>> read only = No
>> browsable = No
>> And then use ADUC or ldbedit to specify the connect to attribute and set
>> it to \\servername\data\%username%
> Hi Matthieu,
> That looks promising. Will cifs symlink, or are we still at ext4 level 
> here?
> Are you saying that a real student e.g.
> /home2/students/year7/year7a/steve
> has a symlink in
> /home2/students/data
> ??
> Would that be e.g. for student steve:
> ln -s /home2/students/year7/year7a/steve /home2/students/data/steve
> (or is the link the other way around?)
> All students then have a link in
> /home2/students/data/<name>
> irrespective of which class they are in.
> For all students, I then map, e.g.  Z:
>  to
> \\servername\data\%USERNAME%
> Am I close?

Well, that would probably work but we have a similar problem and took a 
different approach. We configure a net share through a logon script for our 
users. In our smb.conf, we configure samba to call a  perl script called 
sambalogon like this:

 root preexec = /usr/local/sbin/sambalogin %U %m %M %G %L
 root postexec = rm -f /var/lib/samba/netlogon/%U.bat

The preexec script generates a Windows batch script that  maps the user's 
home to their X: drive. The postexec command deletes the Windows batch file. 
In the perl script, we  do an ldap query to get the user's home and then put 
a "net use" command into the batch script that maps their home to their X: 

 open LOGON, ">/var/lib/samba/netlogon/$user.bat";
 print LOGON "\@ECHO OFF\r\n";
 my $home = &gethome ($user, $group);
 if ($home)
  { print LOGON "NET USE X: \\\\$home\\homes\r\n"; }

The exact contents of the gethome function is left as an excersize for the 

More information about the samba mailing list