IT dragons tamed since 2006 (with 760 solutions and growing)

[login]
[join]

your IP[54.221.93.187]




If you thought this solution was helpfull, please login and vote. Not a member? click here

ID747
TitleSolaris 11.3 ldap login not creating home directory
Byjohn
Keywordsldap autofs auto_master
CategorySolaris 10
Votes0
Views52
Score52
Date2017-04-21
Body
1. Create a file containing the script listed below in /etc/auto_homedir

2. chmod +t+x /etc/auto_homedir

3. change the file /etc/auto_master
replace /home          auto_home       -nobrowse
with /home           /etc/auto_homedir

4. svcadm restart autofs


============SCRIPT BELOW====================
#!/usr/bin/bash
#
# Automounter executable script.
# This script must be referenced in file /etc/auto_master in order
# to have any effect. Furthermore it must have the sticky bit set.
#
# This script receives as $1 the name of the object (file or directory)
# that is being accessed under the moint point. For example if the
# moint point is /home and someone is accessing /home/johndoe then
# $1 will be "johndoe".
# The script is expected to write the path of the physical location
# on stdout.

# ------------------------------------------------------------------------------
# Customizations

# Path of our mount point. This must be the same as the name
# in the first column in the file /etc/auto_master.
HOMEDIRPATH=/home

# Where the physical user home directories are
PHYSICALDIRPATH=/export/home

# The group owner to give to a user's home directory
HOMEDIRGROUP=30001
# ------------------------------------------------------------------------------

hdir=$(eval echo ~${1})

# Sanity check
if [[ $hdir != $HOMEDIRPATH/* ]]; then
# Someone is trying to access a directory under $HOMEDIRPATH
# which is not the name of a user. This we simply ignore, i.e. we exit
# without writing anything on stdout. This will make the automounter
# ignore the action and thus the user will get an error.
exit
fi

# Now we know that $1 is a valid user with a home directory
# under $HOMEDIRPATH

# Next see if the user's physical home dir exist. If not create it.
phdir="$PHYSICALDIRPATH/$1"

if [ -d "$phdir" ]; then
# Yes the user's physical home dir already exist.
# Return the path of the physical home dir to the automounter
# and exit.
echo "localhost:$phdir"
exit
fi

# Create the directory
mkdir -p $phdir

# At this point we can copy setup files into the user's home directory
# e.g. files from /etc/skel. This step is optional.

# Example for Bash logins :
cp /etc/skel/.[a-zA-Z0-9]* ${phdir}/

# Set owner and group
chown -R "$1":"$HOMEDIRGROUP" $phdir

# This was all we needed to do.
# Return the path of the physical home dir to the automounter
# and exit.
echo "localhost:$phdir"

exit
SharediggDigg this solutiondel.icio.usPost to del.icio.usSlashdotSlashdot it!email to a friend
PrintPrint This Solution Print
If you thought this solution was helpfull, please login and vote. Not a member? click here


Latest News

Thanks to Dave for hosting this site!

Registered User Area

[login]
[new user]


Paying the Rent



Advanced Search:

Choose body, keywords, title, or all to include in search 
words to include in search 
and(+)

Choose body, keywords, title, or all to include in search 
additional words to include in search 
not(-)

Choose body, keywords, title, or all to exclude in search 
words to exclude from search 


catagory
order by






diggDigg Dracko
del.icio.usPost to del.icio.us
SlashdotSlashdot us!




Don't forget to vote!
Powered by John Core
Bye!

Dracko by John Core

me

View John Core's profile on LinkedIn


Certifications
security logo saber ccsa logo ccna-logo hbss veritas

Technologies
oracle_logo
solaris_logo linux-logo openstack_logo vbox_logo splunk storagetek_logo sun_logo oraclevm_logo brocade_logo bsd_logo

Languages
c-logo bash-logo php-logo

Employers
PlanetPayment Medecision AWi PennStateHershey DISA DLA cim Sun

Consulting
KMBS PNC FBI CCS PTD Sentinel