samba ldap
来源:互联网 发布:一组数据如何找规律 编辑:程序博客网 时间:2024/06/06 01:32
账号信息存储位置
===============
用smbldap-useradd -m -a -P user 添加的帳號只有儲存在LDAP上,這裏包括了系統帳號及samba帳號。
用useradd username 添加的帳號只儲存在 /etc/passwd 和 /etc/group上。用smbpasswd -a username 添加的帳號只儲存在 /etc/samba/smbpasswd上。
LDAP及SAMBA讓使用者可以自行更改密碼
也可以同步更新 unix 的密碼。
當然,我的 smb & unix account 都是整合在 ldap 資料庫中的。
我使用的工具是 smbldap-tools 所提供的,設定如下:
unix password sync = Yes
passwd program = /opt/IDEALX/sbin/smbldap-passwd -u %u
passwd chat = "Changing password for*\nNew password*" %n\n "*Retype new password*" %n\n
smbldap-passwd 可以用一般 user 來執行,但不能修改別人的。
若不加參數,會同時修改 unix & smb 的密碼。
若 -s 則只修改 smb ; -u 則只修改 unix 。
不過,我的實作裡發現,不用參數時,只修改了 smb 的密碼。
非得再跑一次 -u 才能修改 unix 密碼。
------------------------------------------------------------------------
ubuntu官网之OpenLDAP Server: https://help.ubuntu.com/10.04/serverguide/openldap-server.html
ubuntu官网之FAQ : http://ubuntuforums.org/showthread.php?t=1488232
------------------------------------------------------------------------
openldap安装
openldap增删改查
-----------------
查dc=example,dc=com条目下全部子条目
$ ldapsearch -xLLL -b "dc=example,dc=com"
删条目uid=foo,ou=people,dc=example,dc=com
$ ldapdelete -x -w oswzb -D "cn=admin,dc=example,dc=com" "uid=foo,ou=people,dc=example,dc=com"
增加组条目cn=example,ou=groups,dc=example,dc=com
$ cat group-example.ldif
dn: cn=example,ou=groups,dc=example,dc=com
objectClass: posixGroup
cn: example
gidNumber: 8000
$ ldapadd -x -w oswzb -D "cn=admin,dc=example,dc=com" -f group-example.ldif
adding new entry "cn=example,ou=groups,dc=example,dc=com"
增加条目uid=foo,ou=people,dc=example,dc=com
$ cat foo.ldif
dn: uid=foo,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: foo
sn: li
givenName: foo
cn: li foo
displayName: li foo
uidNumber: 8001
gidNumber: 8000
userPassword: oswzb
gecos: li foo
loginShell: /bin/bash
homeDirectory: /home/foo
shadowExpire: -1
shadowFlag: 0
shadowWarning: 7
shadowMin: 8
shadowMax: 999999
shadowLastChange: 10877
mail: li.foo@example.com
postalCode: 31000
l: Toulouse
o: Example
mobile: +33 (0)6 xx xx xx xx
homePhone: +33 (0)5 xx xx xx xx
title: System Administrator
postalAddress:
initials: JD
$ ldapadd -x -w oswzb -D "cn=admin,dc=example,dc=com" -f foo.ldif
adding new entry "uid=foo,ou=people,dc=example,dc=com"
[gerrit]
basePath = git
canonicalWebUrl = *
[database]
type = h2
database = db/ReviewDB
[auth]
type = LDAP
[sendemail]
smtpServer = localhost
[container]
user = gerrit
javaHome = /opt/jdk1.6.0_25/jre
[sshd]
listenAddress = *:29418
[ldap]
server = ldap://192.168.1.97
username = cn=admin,dc=example,dc=com
accountBase = ou=people,dc=example,dc=com
accountPattern = (&(objectClass=person)(cn=${username}))
sslVerify = false
[cache]
directory = cache
============================================================================
参考ubuntu官网 https://help.ubuntu.com/10.04/serverguide/samba-ldap.html
============================================================================
安装samba和smbldap组件包
------------------------
$ sudo apt-get install samba samba-doc smbldap-tools
拷贝解压samba.schema
--------------------
$ sudo cp /usr/share/doc/samba-doc/examples/LDAP/samba.schema.gz /etc/ldap/schema/
$ sudo gzip -d /etc/ldap/schema/samba.schema.gz
$ vi schema_convert.conf
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/collective.schema
include /etc/ldap/schema/corba.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/duaconf.schema
include /etc/ldap/schema/dyngroup.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/java.schema
include /etc/ldap/schema/misc.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/openldap.schema
include /etc/ldap/schema/ppolicy.schema
include /etc/ldap/schema/samba.schema
$ mkdir /tmp/ldif_output
$ slapcat -f schema_convert.conf -F /tmp/ldif_output -n0 -s "cn={12}samba,cn=schema,cn=config" > /tmp/cn=samba.ldif
修改/tmp/cn\=samba.ldif里内容如下
$ vi /tmp/cn\=samba.ldif
dn: cn=samba,cn=schema,cn=config
...
cn: samba
删掉/tmp/cn\=samba.ldif里以下内容
structuralObjectClass: olcSchemaConfig
entryUUID: b53b75ca-083f-102d-9fff-2f64fd123c95
creatorsName: cn=config
createTimestamp: 20080827045234Z
entryCSN: 20080827045234.341425Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20080827045234Z
增加samba组件到目录里生效
---------------------------
$ sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/cn\=samba.ldif
查询增加samba组件到目录里内容
$ sudo ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn
增加samba组件额外属性
----------------------
vi samba_indexes.ldif
dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: uidNumber eq
olcDbIndex: gidNumber eq
olcDbIndex: loginShell eq
olcDbIndex: uid eq,pres,sub
olcDbIndex: memberUid eq,pres,sub
olcDbIndex: uniqueMember eq,pres
olcDbIndex: sambaSID eq
olcDbIndex: sambaPrimaryGroupSID eq
olcDbIndex: sambaGroupType eq
olcDbIndex: sambaSIDList eq
olcDbIndex: sambaDomainName eq
olcDbIndex: default sub
增加samba组件额外属性到目录里生效
---------------------------------
$ sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f samba_indexes.ldif
[sudo] password for os-weizb:
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}hdb,cn=config"
查询确认增加samba组件额外属性是否在目录里
$ sudo ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=config olcDatabase={1}hdb
$ sudo /etc/init.d/slapd restart
/etc/smbldap-tools/smbldap.conf
/etc/smbldap-tools/smbldap_bind.conf
查询用户(uid=john)信息
------------------------------------------------
$ ldapsearch -xLLL -b "dc=example,dc=com" uid=john
查询所有用户信息
------------------------------------------------
$ ldapsearch -xLLL -b "dc=example,dc=com"
$ sudo smbldap-groupadd -a -g 5000 os-group
$ sudo smbldap-useradd -a -P -d /home/os-test -u 5000 -G os-group os-test
- LDAP+SAMBA
- samba ldap
- LDAP客户端+Samba架设指南
- SAMBA+LDAP ERROR“smbd dead but pid file exists”
- LDAP 整合—— svn、samba、vsftpd --用户密码同步
- 搭建ldap,samba和nfs 统一认证服务
- LDAP
- LDAP
- LDAP
- LDAP
- ldap
- LDAP
- LDAP
- LDAP
- LDAP
- LDAP
- LDAP
- LDAP
- hdu 1062 字符串处理
- python tips(3)
- 比特币介绍和投资分析
- VirtualBox虚拟机网络设置(四种方式)
- 利用sql语句随机抽取记录
- samba ldap
- Visual leak Detact 如何获取当前程序的堆栈
- 设计模式之享元模式
- Android SDK+Eclipse+ADT+CDT+NDK 开发环境在windows 7下的搭建
- 基于QT的小游戏-细菌病毒战
- linux异步信号handle浅析
- Edit Box 详解2
- 程序员的生活
- 设计模式概述