Chinaunix首页 | 论坛 | 博客
  • 博客访问: 587042
  • 博文数量: 70
  • 博客积分: 3219
  • 博客等级: 中校
  • 技术积分: 1197
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-13 12:20
个人简介

谢谢您的对我的博客的关心,同时希望这个站点真的能够对您有所帮助。 如果可以请告诉我你的联系方式(可能的话告诉我两个或更多,我不希望失去任何一个关注本主页人士的联系,不论你是我的老友,或是一位新朋友,对于我来说您十分重要)

文章分类
文章存档

2021年(1)

2020年(13)

2018年(1)

2013年(12)

2012年(2)

2009年(2)

2008年(6)

2007年(20)

2006年(13)

分类: LINUX

2009-01-19 14:22:00

本文非原创,参考了下文,做了适当修改,并在CentOS 4.X 和CentOS 5.X 上测试成功:



  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的源码包:

      # 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权限执行没此要求。

阅读(4345) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

split_two2013-05-03 13:38:34

您好!问下我LDAP基本配置完了,也能正常登录,现在就是加入samba模板的后重启ldap服务,没有提示加入模板,网页登录也没有samba相关的东西,samba源码包是从你提供的地址下载的,是不是模板有问题呢?或者说我用系统自带的samba模板OK吗?请指点指点!