how to enable nss-wrapper in samba 4.3.9

Fengwei feng.wei at
Fri Dec 16 01:31:11 UTC 2016

Hi all,
Thanks for your attetion to my question.I have another quetion about the samba.
If a user account has got through the LDAP authentication for samba,samba will use the function getpwnam() to obtain user information.The function
getpwnam() is in CNU C Library and the Name Service Switch(NSS) configuration file, /etc/nsswitch.conf is used by this function to determine the sources from which to obtain name-service information in a range of categories, and in what order. I set the /etc/nsswitch.conf file as follows:
         passwd:         compat ldap
         group:          compat ldap
         shadow:         compat ldap

         hosts:          files dns
         networks:       files

         protocols:      db files
         services:       db files
         ethers:         db files
         rpc:            db files

         netgroup:       nis
As a result, if the user account has the same name as in LDAP,samba will get the user information from the local file, /etc/passwd. How can samba get the user information from ldap but not to change the the order of the services in the passwd database? I don't want to change the contents of the /etc/nsswich.conf file because this file may have an effect on other applications.

发件人: Andreas Schneider [mailto:asn at]
发送时间: 2016年12月14日 14:47
收件人: samba-technical at
抄送: shaojianxiong 13052 (RD); fengwei 11322 (RD)
主题: Re: how to enable nss-wrapper in samba 4.3.9

On Wednesday, 14 December 2016 00:46:24 CET Fengwei wrote:
> Hi all:
>          Thanks for your attention. I have a question about
> nss_wrapper library.
 I want to get user and group information from my own passwd and
> group files in samba 4.3.9. So I use the package
> 'nss_wrapper'.Firstly,I install the nss_wrapper library;Secondly, I
> use the function setenv() to set,
> NSS_WRAPPER_PASSWD = passwd and NSS_WRAPPER_GROUP=group in smbd, but
> it doesn't work. I want to ask how to enable nss-wrapper and get user
> and group information from my own passwd and group files in samba 4.3.9? Thanks.


nss_wrapper is not really meant for production, it is a testing tool :-).
However you need to preload nss_wrapper before you start smbd. Doing it in smbd is wrong and too late.

See 'man'


Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at

This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!

More information about the samba-technical mailing list