But still we can see that user authenticate without getting its own home folder, so there is still some work left in which user wants to work on shell & saving data on file server or in his home folder. We need to mount the respective home folder on client machines. Here we will describe two types of mounting one through the file change & another in which setting will be used to configure in LDAP database itself & populate to whole domain.

Before we start the work we should understand few important things about these kinds of mountings, basically most of time mountings are doing their normal work like for using disk partition. But sometime we need to have mount points which are exported from the remote machines, they can many types or from various protocols like NFS, FTP, SMB etc
Here we using the service called Autofs, which is for automatic mounting of the home folders from the Server as the user login on the Client machine.
In our previous post with Openldap Server configuration, we made user with the home folder in /home, In this case whenever we have some local user on Client machine, and then it gets problem during autofs. So it’s not a good practice to make LDAP users with home folders in /home on Server. Try it to avoid as much as possible. Even if you made some users in same fashion you can change home folder location in ldif files during before ldapadd command on LDAP Server & move home folders to specific location.

Now let’s back to work to implement the real admin work.
First I try for the file editing procedure that needs some kinds of editing over the file level in Linux for the auto mounting of home folder as the user login on client machine.

For exporting or sharing the home folders, here I am using NFS Service.

So for this here we make NFS Server on Openldap Server for exporting the home folders.
Install NFS Packages on Server & edit the /etc/exports file.
[root@srv3 ~]# echo “/home           *(rw,sync)”  > /etc/exports
 [root@srv3 ~]# cat /etc/exports
/home           *(rw,sync)
[root@srv3 ~]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                    [  OK  ]
Starting NFS mountd:                                     [  OK  ]

Now it’s time for editing in Client side.
Edit the /etc/auto.master file, add this line in bottom.

[root@srv12 ~]# cat /etc/auto.master
# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
/misc /etc/auto.misc
# NOTE: mounts done from a hosts map will be mounted with the
# “nosuid” and “nodev” options unless the “suid” and “dev”
# options are explicitly given.
/net -hosts
# Include central master map if it can be found using
# nsswitch sources.
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
/home /etc/auto.home

Here we mention two things in this file, one is on which local folder we try to mount the user’s home folder, and it should whatever you mention in ldif file at the time of ldapadd command & second derivates is the file name where we will mentioning the address of the share to mount.

Now edit the second file /etc/auto.home file
[root@srv12 ~]# cat /etc/auto.home
*       –fstype=nfs

[root@srv12 ~]# service autofs start
Starting automount:                                        [  OK  ]

Here we can see now u1 user can able to login on the srv12 Client and user gets its home folder as they loin, They able to make file & directories on their home folders.
But in this all editing is on Client side every time. When ever there is any change in Server all the Client have to update or with every change on Server we have take care of the Client configuartion. For this we use autofs in LDAP schema as well, means any change in Server will never dependent on the Client side.

For auto mounting with LDAP database, we have to do some changes on LDAP Server. Which are like this.
First we have to edit the main configuration file Openldap in directory /etc/openldap, it is slapd.conf.
Here we have to add one more schema file support on slapd.conf. In this last line is added for autofs schema
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/redhat/autofs.schema

So here we have a database which will be populated on the network to share the home folders location, it is not important
Mounting need share, In Linux various services can share like NFS, SAMBA, FTP & HTTP etc. Here we just share the home folders through the NFS service. Let’s do the same.
On Server it’s is same as for the sharing of the home folders, there is only add of one file in the ldap database through “ldapadd” command.

This is file that we add for the autofs LDAP automounting.
[root@srv3 ~]# cat automount.ldif
dn: ou=auto.master,dc=linuxphobia,dc=com
ou: auto.master
objectClass: top
objectClass: automountMap

dn: cn=/home,ou=auto.master,dc=linuxphobia,dc=com
objectClass: automount
cn: /home
automountInformation: ldap,dc=linuxphobia,dc=com

dn: ou=auto.home,dc=linuxphobia,dc=com
ou: auto.home
objectClass: top
objectClass: automountmap

dn: cn=/,ou=auto.home,dc=linuxphobia,dc=com
cn: /
objectClass: automount
automountInformation: -rsize=8192,wsize=8192,intr

Add  this file with “ldapadd” command like this.

[root@srv3 ~]# ldapadd -x -D “cn=admin,dc=linuxphobia,dc=com” -W -f automount.ldif

Now there is only little change in the Client side for autofs, that mostley can deployed during the installation with kickstart file installation, This is in /etc/sysconfig/autofs.
[root@srv12 ~]# grep -v ^# /etc/sysconfig/autofs

After this start the autofs service.

[root@srv12 ~]# service autofs start
Starting automount:                                        [  OK  ]

There is small video for this.

Here i want to share one important concept with you about the home folders locations. In our case users in LDAP database are also a system users, So when ever we made some users in Linux system it make home folders in /home by default & when ever we try migrate our users from this system users database means from /etc/passwd through migration scripts, It just migrate the same home folder locations to the LDAP database. This comes problem, as we try to mount this on Client through auto mount because it tries to mount /home of Client. This create problem with the local users home folders.

So here is an advise for everyone Please try to make a difference in between local & LDAP users in LDAP Server, For this home folder locations should not be /home, you can choose like /userdata for LDAP users.
As for example if you add some users with homefolders in /userdata, for this you just need to add some small kind of changes in ldif files of the u1 which is u1.ldif used earlier in post. like you want to add new users name lokesh with home folder /userdata/lokesh then just  open the file u1.ldif in vim and use %s/u1/lokesh/g  & yes one more thing also replace /home/u1 with /userdata/lokesh & uid for the lokesh like 501(search with ldapsearch which is not assign to anyone) , Then now you have file for your user with home folder in /userdata. just add this file with “ldapadd” command in LDAP database. Please remind to make directories /userdata/lokesh & change ownership, permission for lokesh with these commands
mkdir -p /userdata/lokesh
chmod 700 /userdata/lokesh
chown  uid:uid /userdata/lokesh —> uid here is assigned uid for lokesh

One last thing, how to automount through LDAP database again for /userdata, then use this ldif file for /userdata.Please see it carefully it is for whom who already follow the post, means if you just add for /userdata not /home then please also add ou auto.master from earlier autolount.ldif with using first 4 lines lines above this file.

#cat userdata.ldif

dn: cn=/userdata,ou=auto.master,dc=linuxphobia,dc=com
objectClass: automount
cn: /userdata
automountInformation: ldap,dc=linuxphobia,dc=com

dn: ou=auto.userdata,dc=linuxphobia,dc=com
ou: auto.userdata
objectClass: top
objectClass: automountmap

dn: cn=/,ou=auto.userdata,dc=linuxphobia,dc=com
cn: /
objectClass: automount
automountInformation: -rsize=8192,wsize=8192,intr