Jan 24

SLES 11 - SAMBA + LDAP

Category: Nox

As promised in my last post regarding SLES11, I chose Samba + Openldap to be the first 2 services I’m going to try for the operational and stability in SLES11. Since we all knew this is trivial job for some system admin to configure both services and make it running well on SLES10 and some Linux Distro.

Objectives:

  • To have Samba file sharing and user authentication via LDAP server.

Software Requirements:

  • Samba Version 3.2.7-11.6-2057-SUSE-CODE11
  • Openldap2-2.4.12-7.14
  • perl

Notes : All software will be installed by default during SLES11 installation. However I still have to install “perl-ldap” before I can run any “smbldap-tools” command.
Additional Software

  • smbldap-tools-0.9.5-26.1

Samba+Ldap also require “smbldap-tools” for user & group operation. Unfortunately, akin to the previous one, SLES11 also doesn’t come with “smbldap-tools”. I have to download it manually from somewhere which I forgot where :)

Notes : Once I downloaded & installed it on my SLES11, “smbldap-tools” not working properly and produced an error such “Can’t locate Unicode/MapUTF8.pm in @INC“. This can be resolved by manually run this command on my SLES11 system $perl -MCPAN -e ‘install Unicode::MapUTF8′

OPENLDAP CONFIGURATION

This can be done fairy easy from YasT2 and I just need to select the default one and use my proper base DN and Administrator login. However in SLES11, Openldap don’t use default slapd.conf which come together with the package, instead slapd.conf.YaST will be used.
ldap-server.png

Once everything done, start the Ldap server, and review the entry in my Ldap server via free tool call “LdapAdmin”.

ldap-admin.png

Notes : You can view, create and modify Ldap object via LdapAdmin without problem. Unfortunately, LdapAdmin sometime failed to create successfully Ldap user account which require samba/unix integration. However, we can achieve this via “smbldap-tools” command.

SMBLDAP-TOOL CONFIGURATION

First I need to install this rpm packages “$rpm -ivh smbldap-tools-0.9.5-26.1” then modify two files as below for my Ldap environment:

  • smbldap.conf
  • smbldap_bind.conf

Now I’m going to create Ldap group call “finance” via .ldif format as below

$cat /var/lib/ldap/groups-bak.ldif
dn: cn=finance,ou=groups,dc=no-x,dc=org
objectClass: posixGroup
objectClass: top
objectClass: namedObject
cn: finance
userPassword: {crypt}x
gidNumber: 1001

$ldapadd -x -D “cn=Administrator,dc=no-x,dc=org” -W -f /var/lib/ldap/groups-bak.ldif

Enter LDAP Password:
adding new entry “cn=finance,ou=groups,dc=no-x,dc=org” 

Then, create unix group “finance” as below :

$groupadd -g 1001 finance (Make sure gid number is similar with the one in .ldif)

Once finished, I link it between both Ldap and Unix group for RID via LdapAdmin as below :

ldap-admin-mapping.png groupmap-list.png
As you can see both Samba group now link together successfully with Unix group. Now I will move user “faisyal” to this group with $smbldap-usermod -G finance faisyal. Since I don’t installed nss_ldap & pam_ldap, only Samba+ldap entry will be modified and Unix group will be remained as is. As attachment below, you can see user “faisyal” fall under “finance” Samba+ldap group but in Unix, he still sitting under group “admin” and able to access share folder (valid user=admin) //192.168.1.95/test while other user cannot.

smb-group.png

To correct this, I have to manually move the user in unix manually via command $usermod -a -G finance faisyal. New user creation for both Samba+Ldap and Unix user account can be done with below command though it doesn’t populate the user to proper Unix group:

$smbldap-useradd -a -g 1001 -m -s /bin/bash -d /home/faisyal -F “” -P faisyal

Okay will continue this later. I have to go for my company dinner now….

ariyossss

PART II

Okay, after one hour hard work, I can confirm that my samba+ldap on SLES11 now running very well. Just need minor configuration as below :

  • Install nss_ldap from YaST2
  • Install pam_ldap from YaST2
  • Configure LDAP Client from YaST2

Once finished all three configuration above I just create new user “febry” group “finance” and vola! he can access samba /finance folder belong to “finance” group without problem.

$smbldap-useradd -a -G ‘finance’ -m -s /bin/bash -d /home/febry -F “” -P febry

smbldap-useradd-final-ok.png nsswitch-ldap.png

Notes :

  • When you, finished configured as PART II above, you will noticed there are some changes on /etc/nsswitch.conf
  • New user creation via “smbldap-useradd” will create user in samba, ldap and user home directory. However, no user account will be created in /etc/passwd & /etc/group.
  • Though no new user entry in /etc/passwd, user still can connect to server via ssh using ldap authentication

ariyossss

athlon_crazy 26/01/2009 2:04am

2 Comments so far

  1. GV November 12th, 2010 11:46 pm

    in my SLES11

    perl -MCPAN -e ‘install Unicode::MapUTF8′

    fails:


    Running Build test
    t/01_unicode_maputf8….Can’t locate Unicode/String.pm in @INC (@INC contains: ./blib ../blib ../lib ./lib /root/.cpan/build/Unicode-MapUTF8-1.11-6Wzeo7/blib/lib /root/.cpan/build/Unicode-MapUTF8-1.11-6Wzeo7/blib/arch /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl .) at lib/Unicode/MapUTF8.pm line 5.
    BEGIN failed–compilation aborted at lib/Unicode/MapUTF8.pm line 5.
    Compilation failed in require at t/01_unicode_maputf8.t line 6.
    BEGIN failed–compilation aborted at t/01_unicode_maputf8.t line 6.
    t/01_unicode_maputf8….dubious
    Test returned status 2 (wstat 512, 0×200)
    t/97_distribution…….skipped
    all skipped: Test::Distribution not installed
    t/98_pod_coverage…….skipped
    all skipped: Test::Pod::Coverage 1.06 required for testing POD coverage
    t/99_pod…………….skipped
    all skipped: Test::Pod 1.00 required for testing POD
    FAILED–4 test scripts could be run, alas–no output ever seen
    SNOWHARE/Unicode-MapUTF8-1.11.tar.gz
    ./Build test — NOT OK
    //hint// to see the cpan-testers results for installing this module, try:
    reports SNOWHARE/Unicode-MapUTF8-1.11.tar.gz
    Warning (usually harmless): ‘YAML’ not installed, will not store persistent state
    Running Build install
    make test had returned bad status, won’t install without force

    any ideas?

  2. athlon_crazy November 13th, 2010 4:50 pm

    Probably you had problem installing this required module Test::Pod::Coverage

    1)go to cpan shell then install the module
    $perl -MCPAN -e shell

    2) Force install module
    cpan> force install Pod::Coverage

Leave a comment