免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1111 | 回复: 0
打印 上一主题 下一主题

使用openldap目录服务进行samba用户验证 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-19 14:22 |只看该作者 |倒序浏览

                本文非原创,参考了下文,做了适当修改,并在CentOS 4.X 和CentOS 5.X 上测试成功:
使用openldap目录服务进行samba用户验证
  samba可把用户信息存放到ldap目录服务器上,使用目录服务器上的用户数据进行用户验证。这样做的好处是:
    1. 集中存放用户信息,多台Samba服务器可共用一套用户数据。
    2. 当用户数量多时,采用ldap目录服务器可加快用户验证的速度。因为ldap目录服务是专门为读操作而优化的,搜索数据的速度是非常快的。
    3. 用户可自由更改自已的密码,而不用经过系统管理员,可大大减轻系统管理员的工作量。
一、配置ldap服务
  要 openldap能认识samba的用户信息,我们需在openldap服务器中导入samba.schema。该文件是不包含在openldap源码中的,我们可在samba源码目录中的/examples/LDAP路径中找到该文件。把它拷贝到openldap的schema目录。接着编辑 slapd.conf文件,用include指令把samba.schema导入openldap。如:
到这里下载samba的源码包:
http://us1.samba.org/samba/
      # See slapd.conf(5) for details on configuration options.
      # This file should NOT be world readable.
      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
      include         /etc/openldap/schema/samba.schema                      #导入samba.schema文件
      # Allow LDAPv2 client connections.  This is NOT the default.
      allow bind_v2
  重启ldap服务,使配置生效。
      [root@linux5 ~]# service ldap restart
      Stopping slapd:                                            [  OK  ]
      Checking configuration files for slapd: config file testing succeeded
      Starting slapd:                                            [  OK  ]
二、配置samba服务
  下来我们要配置samba服务器了。打开smb.conf文件,添加以下内容:
      # You may wish to use password encryption. Please read ENCRYPTION.txt,
      # Win95.txt and WinNT.txt in the Samba documentation. Do not enable this
      # option unless you have read those documents
         encrypt passwords = yes
      ;   passdb backend = smbpasswd guest              #取消smbpasswd验证
      ldap admin dn = "cn=Manager,dc=my-domain,dc=com"  #指定管理员,请参考slapd.conf文件
      passdb backend = ldapsam:ldap://192.168.0.7       #指定用户验证的ldap目录服务器的IP地址或主机名
      ldap user suffix = dc=samba,dc=my-domain,dc=com   #用户信息存放的目录路径
      ldap delete dn = no                               #不允许删除dn
      ldap suffix = dc=my-domain,dc=com                 #指定搜索后缀
  存盘退出,重启smb服务。运行以下命令,把cn=Manager,dc=my-domain,dc=com管理员的密码“123456”保存到secrets.tdb文件中,以便samba服务器与openldap服务器进行通信。
      [root@linux5 ~]# service smb restart
      Shutting down SMB services:                                [  OK  ]
      Shutting down NMB services:                                [  OK  ]
      Starting SMB services:                                     [  OK  ]
      Starting NMB services:                                     [  OK  ]
      [root@linux5 ~]# smbpasswd -w 123456
      Setting stored password for "cn=Manager,dc=my-domain,dc=com" in secrets.tdb        #成功保存的提示信息
  千万注意!!这里的密码“123456”,就是slapd.conf文件里指定的管理员的密码!
  配置完成,使用smbpasswd命令就可把用户信息保存到ldap目录服务器上了。
      [root@linux5 ~]# smbpasswd -a dwang
      New SMB password:
      Retype new SMB password:
      Added user dwang.             #成功添加用户
三、设定ldap服务来维护samba帐号
  到此为止,使用ldap目录服务器进行Samba用户验证已配置完成。但现在还是要管理员在samba服务器上使用smbpasswd命令为用户维护密码。从维护工作量和保密的角度出发,由用户自已维护自已的密码是一种最好的方法。具体设置方法是这样的:
  通过目录服务器的权限管理,我们也可把test用户密码属性设置成只有 dn是cn=dwang,dc=samba,dc=it,dc=com的用户和目录服务器管理员才能修改。要达到该项果,请把以下ACL加入到 slapd.conf中。
            access to attrs=sambaLMPassword
                    by dn="cn=Manager,dc=newavetech,dc=com" write
                    by anonymous auth
                    by self write
                    by * none
            access to attrs=sambaNTPassword
                    by dn="cn=Manager,dc=newavetech,dc=com" write
                    by anonymous auth
                    by self write
                    by * none
  重启openldap服务器使配置生效。
  用smbpasswd命令就能修改用户的密码了,不过别忘了原始密码,否则又得劳驾管理员了!
  根据密码复杂度要求,用户自己设的密码至少要有6位,以root权限执行没此要求。
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13902/showart_1803997.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP