LDAP+SAMBA


 


( Lightweight Directory Access Protocol 輕量級名錄存取協定 )
在 redhat 9 用 rpm包 安裝
因為 Samba3 預設就有 Ldap 支援,Samba 2 要先編譯再安裝比較麻煩,乾脆重新安裝 Samba3
samba 3.x 安裝之前先移除 samba 2.x 的版本
#rpm -e samba-swat
#rpm -e samba-client
#rpm -e redhat-config-samba
#rpm -e samba
#rpm -e samba-common
#rpm -ivh samba-3.0.2a-1_rh9.i386.rpm (只有一包)
修改 smb.conf
;   wins support = yes (作為 wins service 的 slave 接受 163.32.225.4 的管控)
wins server 163.32.225.4 (向本校的 wins server 去報到)
logon script = %U.bat :個人設定檔
logon path = %L%U.profiles :個人設定檔位置
logon home = %L%U.profiles
[homes]
   comment = Home Directories
   browseable = no
   writable = yes :家目錄權限
   valid users = %S
   create mode = 0664
   directory mode = 0775
[netlogon] :登入指令稿
   comment = Network Logon Service
   path = /home/netlogon :登入指令稿位置
   guest ok = yes :登入指令稿權限
   writable = no
   share modes = no
/home/netlogon/jnur.bat :登入指令稿
net use h: /hoem(ctrl+v)(ctrl+m) :斷行
從redhat 9 disk1、disk2分別取得4個套件包
rpm -ivh openldap-2.0.27-8.i386.rpm
rpm -ivh openldap-servers-2.0.27-8.i386.rpm
rpm -ivh openldap-clients-2.0.27-8.i386.rpm
rpm -ivh openldap-devel-2.0.27-8.i386.rpm
修改/etc/openldap/slapd.conf
database        ldbm
suffix          "dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw"
rootdn          "cn=Manager,dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw"
rootpw         {SSHA}83DJ4KVwqlk1uh9k2uDb8+NT1U4RgkEs
directory       /var/lib/ldap/【須把ldap資料夾的權限開到777讓ldapsearch -x才讀得到】
管理者密碼的製造過程
#slappasswd
New password
Re-enter new password
{SSHA}83DJ4KVwqlk1uh9k2uDb8+NT1U4RgkEs
啟動 service ldap start
自行編輯一個 .ldif 檔
新增第一筆 basedn.ldif (Base Distinguish Name)資料至 openldap
#vi basedn.ldif
#建立根節點
dn:dc=ldap,dc=hmes.kh.edu.tw
dc:ldap
objectclass:dcobject
objectClass: top
objectclass:organizationalUnit
ou:ldaper
#建group ou
dn: ou=group,dc=ldap,dc=hmes.kh.edu.tw
objectClass: top
objectClass: organizationalUnit
ou: group
description: system groups
#建teacher ou
dn: ou=teacher,dc=ldap,dc=hmes.kh.edu.tw
objectClass: top
objectClass: organizationalUnit
ou: teacher
description: teachers account
#建student ou
dn: ou=student,dc=ldap,dc=hmes.kh.edu.tw
objectClass: top
objectClass: organizationalUnit
ou: student
description: students account
#建machine ou
dn: ou=machine,dc=ldap,dc=hmes.kh.edu.tw
objectClass: top
objectClass: organizationalUnit
ou: machine
description: machines account
#建admin ou
dn: ou=admin,dc=ldap,dc=hmes.kh.edu.tw
objectClass: top
objectClass: organizationalUnit
ou: admin
description: Administrators account
加入最初名錄項目:在ldap停機狀態下(否則仍會搜索到資料,但是.tdb已經不見了)
# slapadd -v -l /home/user/wplee/basedn.ldif
測試:#ldapsearch -x -b "dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw""(objectclass=*)"
結果
# filter: (objectClass=*)
# requesting: ALL
#
# ldap, hmes, kh, edu, tw
dn: dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw
objectClass: top
# search result
search: 2
result: 0 Success【0:指的是搜索成� 32:是指搜索不到指定的DN】
# numResponses: 3
# numEntries: 2
將 /etc/passwd 轉出 .ldif
先設定 migrate_common.ph 的 $DEFAULT_BASE 變數
#vi /usr/share/openldap/migration/migrate_common.ph 改 $DEFAULT_BASE "dc=hmes,dc=kh,dc=edu,dc=tw";
用 migrate_passwd.pl Perl命令稿把系統檔轉譯成 ldif 檔案,方便匯入LDAP資料庫
#/usr/share/openldap/migration/migrate_passwd.pl  /home/wplee/passwd.ldif
(用 migrate_passwd.pl 將 /etc/passwd 轉出到 /home/wplee/passwd.ldif)
在 LDAP 下使用中文(例如 /etc/passwd 裡有中文註解)
% iconv -f big5 -t utf-8 big5.ldif > utf-8.ldif
然後用 ldapadd 來將 utf-8.ldif 轉入 ldap 。
samba 要與 openldap 溝通前,samba 要先將 openldap 的密碼存在 /etc/samba/secrets.tdb,密碼就是剛剛設定 openldap 時要一樣
#smbpasswd -w secret
setting stored password for "cn=Manager,dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw" in secrets.tdb
【smbpasswd -w】的意思是設定 ldap admin password
最後我們還要新增 openldap 使用者的資料,才能給 samba 使用
#smbpasswd -a jnru
檢查結果
ldapsearch -x -b "uid=jnru,dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw"
version: 2
#
# filter: (objectclass=*)
# requesting: ALL
#
# jnru, ldap, hmes, kh, edu, tw
dn: uid=jnru,dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw
uid: jnru
cn: jnrulay
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
objectClass: sambaSamAccount
userPassword:: e2NyeXB0fSQxJHpXQkFab0I0JGJ2encxLk1rS3VRRE1rbFRiRDVoazE=
shadowLastChange: 12487
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 501
gidNumber: 500
homeDirectory: /home/jnru
gecos: jnrulay
sambaSID: S-1-5-21-2196867991-451936805-2971247903-2002
sambaPrimaryGroupSID: S-1-5-21-2196867991-451936805-2971247903-2001
sambaPwdCanChange: 1078923157
sambaPwdMustChange: 2147483647
sambaLMPassword: C46F43B40CBE4D45613E9293942509F0
sambaNTPassword: A326F3EA1864FA8540959365D7DD7D30
sambaPwdLastSet: 1078923157
sambaAcctFlags: [U          ]
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
加入機器帳號
useradd -g machine -d /dev/null -c 註解 -s /bin/false 機器帳號$
smbpasswd -a -m 機器名稱
說明 -c:是註解,可用""夾註起來
-s:/bin/false 不登入
機器帳號後面要加$號
smbpasswd -m 機器帳號不用加$
自動建機器帳號
net ads join -U Administrator%Password
在smb.conf裡的[global]加
add user script = /usr/sbin/useradd -d /dev/null -g machines -s /bin/false -M %u (Samba 2.x)
add machind script = /usr/sbin/useradd -d /dev/null -g 100 -s /bin/false -M %u (Samba 3.x)
samba with ldap 還有一些工具程式在 /usr/share/doc/samba-3.0.2a/examples/LDAP/smbldap-tools/ 裡
其中的 ldapsync.pl 和 ldapchpasswd
當 samba 是 pdc 時
ldapsync.pl 可以讓 win2000或xp 直接修改密碼
ldapchpasswd 可以讓 linux或其他client 修改密碼
●openldap可使用的工具有
/usr/share/openldap/migration/
/usr/share/doc/samba-3.0.2/examples/LDAP/smbldap-tools/
●使用 smbldap-tools
smbldap-tools使用了perl5的perl-ldap的module,perl-ldap的module又需要Convert::ASN1.pm
總之:先安裝 Convert-ASN1-0.18.tar.gz 再安裝 perl-ldap-0.31.tar.gz 然後修改smbldap-tools/smbldap_conf.pm就可以使用了
tar Convert-ASN1-0.18.tar.gz
  gunzip Convert-ASN1-x.xx.tar.gz
  tar xvf Convert-ASN1-x.xx.tar
  cd Convert-ASN1-x.xx
  perl Makefile.PL
  make
  make test
  make install
tar 開 perl-ldap-0.31.tar.gz 後 cd 進 perl-ldap-0.31
perl Makefile.PL
make
make test
make install
/usr/share/doc/samba-3.0.2a/examples/LDAP/smbldap-tools/
cgi             Makefile             smbldap-groupmod.pl          smbldap-tools.spec
ChangeLog       mkntpwd              smbldap-groupshow.pl         smbldap-useradd.pl
CONTRIBUTORS    README               smbldap-migrate-accounts.pl  smbldap-userdel.pl
COPYING         smbldap_conf.pm      smbldap-migrate-groups.pl    smbldap-usermod.pl
FILES           smbldap_conf.pm.bak  smbldap-passwd.pl            smbldap-usershow.pl
INFRASTRUCTURE  smbldap-groupadd.pl  smbldap-populate.pl          TODO
INSTALL         smbldap-groupdel.pl  smbldap_tools.pm
有這麼多,全部cp到/usr/local/sbin/目錄下
# vi smbldap_conf.pm 要注意或修改的有以下......
# UID and GID starting at...
$UID_START = 1000;
$GID_START = 1000;
$masterLDAP = "127.0.0.1";
$masterPort = "389";
$suffix = "dc=ldap,dc=hmes,dc=kh,dc=edu,dc=tw";
$usersdn = "ou=People,$suffix";自訂
$computersdn = "ou=machines,$suffix";自訂
$groupsdn = "ou=$groupsou,$suffix";自訂
$bindpasswd = "密碼";
$_userLoginShell = q(_LOGINSHELL_);登入指令稿的路徑
$_userHomePrefix = q(/home/);家目錄的位置
$_defaultUserGid = 1001;自訂
$_defaultComputerGid = 1000;自訂
$_userProfile = q(ldapprofiles);就等於ldapprofiles 使用者設定檔的位置
$_userHomeDrive = q(_HOMEDRIVE_);個人網路磁碟的磁碟代號
以後就可以像 smbldap-useradd.pl -m s30101 這樣來新增 s30101 這個samba user了
以win2000來說,可以按Ctrl+Alt+Del---->>變更密碼---->>修改網域密碼
這個工具一次修改三組user儲存在ldap上的密碼
NTPassword,LMPassword,userPassword
NTPassword,LMPassword 這兩組是samba使用的密碼,userPassword 是一般ldap用來認證其他services的密碼
●要重建ltdb資料庫,必須先service ldap stop,然後再刪除/var/lib/openldap/*的所有檔案,否則資料會馬上回覆,無法重建
●第一次建立名錄後,檔案權限都怪怪的,使得ldapsearch或者Java ldap Browser都無法順利讀取,
必須先chmod 777 /var/lib/openldap這個目錄及裡面的資料庫檔案。然後再改回預設值chmod 700 /var/lib/openldap目錄,chmod 600 /var/lib/openldap/*資料庫檔案。
用 Trustix 2.1 (build 20040430)
新增名錄內容
==========================================================
第一步 擷取 passwd
==========================================================
user s30101 的passwd
s30101:x:501:501:test:/dev/null:/bin/false
==========================================================
第二步 用/usr/share/openldap/migration/migrate_passwd.pl轉換的結果
==========================================================
s30101.ldif
dn: uid=s30101,ou=student,dc=ldap,dc=hmes.kh.edu.tw
uid: s30101
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {SSHA}No4FSvw/KAjpOKCXCJTS2rQXUs4EzRjg
shadowLastChange: 12544
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/false
uidNumber: 501
gidNumber: 501
homeDirectory: /dev/null
gecos: test
==========================================================
第三步用 ldapadd s30101.ldif 的結果,尚未與samba緊密結合
==========================================================
# extended LDIF
#
# LDAPv3
# base with scope sub
# filter: (objectclass=*)
# requesting: ALL
#
# s30101, student, ldap.hmes.kh.edu.tw
dn: uid=s30101,ou=student,dc=ldap,dc=hmes.kh.edu.tw
uid: s30101
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword:: e1NTSEF9Tm80RlN2dy9LQWpwT0tDWENKVFMyclFYVXM0RXpSamc=
shadowLastChange: 12544
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/false
uidNumber: 501
gidNumber: 501
homeDirectory: /dev/null
gecos: test
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
心得整理:
當system 沒有建立 user account ,還是可以獨立建立 Samba user Account,
但是如果直接用 smbpasswd -a [userx],因為 samba server 已經和 LDAP 結合了,
所以會出現 LDAP 沒有相對應名錄的錯誤訊息,所以可以先用 smbldap-tools 的 smbldap-useradd.pl -m [userX] 先建立名錄 ,再用 smbpasswd -a 補齊名錄內容
更改密碼後只有sambaNTPassword的內容有改變,表示 sambaNTPassword 應是logon password
authorconfig 先啟動nscd server
無法更改密碼 :smb.conf 取消   encrypt passwords = yes
用smbldap-useradd.pl新增名錄沒有
sambaLMPassword
sambaNTPassword
sambaPrimaryGroupSID ......等內容,
在XP加入網域時會出現找不到使用者名稱的窘境
要使用smbpasswd -a -m [name]才會有以上的內容
但是如果/etc/passwd沒有該[name]又會有
Failed to initialise SAM_ACCOUNT for user [name].
Failed to modify password entry for user [name]
Use of uninitialized value in string at /usr/local/sbin/smbldap-useradd.pl line 219, line 283.
failed to modify entry: No DN specified at /usr/local/sbin/smbldap-useradd.pl line 224, line 283.
的問題,所以又必須在/etc/passwd先存在該[name]才能使用smbpasswd -a -m
總之,必須想辦法解決smbldap-useradd.pl -w 可以建帳號以外又可以建立sambaLMPassword....等內容
或者讓samba 網域認證去掉檢查sambaLMPassword....
檢視group的SID
# net groupmap list
machine (S-1-5-21-494860000-2996932910-3964857592-3003) -> machine
teacher (S-1-5-21-494860000-2996932910-3964857592-3005) -> 1002
admin (S-1-5-21-494860000-2996932910-3964857592-3007) -> 1003
在98可以登入的帳號,在xp不能登入
因為xp會檢查sambaSID、sambaPrimaryGroupSID 所以錯誤的 SID 帳號會顯示帳號密碼錯誤,而不能登入
sambaSID、sambaPrimaryGroupSID 其實就是samba的SID再加上UID
例如
sambaPrimaryGroupSID:S-1-5-21-3208428661-991213405-406351167-**uid**
sambaSID:S-1-5-21-3208428661-991213405-406351167-**uid**
在 ldap server 端
ldapmodify -x -h 163.32.225.12 -D "cn=Manager,dc=ldap,dc=hmes.kh.edu.tw" -w ****** -f change-sid301.ldif -n
ldapmodify [-a 新增項目]  [-b]  [-c]  [-r]  [-n 測試]  [-v]  [-k]  [-d 除錯level]  
[-D 連結dn]  [-W 提示輸入密碼]  [-w 密碼] [-h ldaphost] [-p 特殊埠號] [-f 檔名]
change-sid301.ldif 內容只有 dn 一行、sambaPrimaryGroupSID  一行、sambaSID  一行
以此方式,還可以修改密碼!
那如何找出正確的帳號SID呢?
如何正確的、大量的建立user account呢?
其實Samba有3種帳號
● 使用者帳號 ( user account ) 可用smbpasswd -a [name] 建立
● 信任電腦帳號 ( machine trust account ) 可用smbpasswd -m [name] 建立
● 信任網域帳號 ( interdomain trust account ) 可用smbpasswd -i [name] 建立

#./smbldap-populate.pl
Using builtin directory structure
adding new entry: dc=ldap,dc=hmes.kh.edu.tw
failed to add entry: Already exists at ./smbldap-populate.pl line 323,  line 2.        已經有了
adding new entry: ou=student,dc=ldap,dc=hmes.kh.edu.tw
failed to add entry: Already exists at ./smbldap-populate.pl line 323,  line 3.        已經有了
adding new entry: ou=group,dc=ldap,dc=hmes.kh.edu.tw
failed to add entry: Already exists at ./smbldap-populate.pl line 323,  line 4.        已經有了
adding new entry: ou=machine,dc=ldap,dc=hmes.kh.edu.tw
failed to add entry: Already exists at ./smbldap-populate.pl line 323,  line 5.        已經有了
adding new entry: uid=Administrator,ou=student,dc=ldap,dc=hmes.kh.edu.tw        新增的
adding new entry: uid=nobody,ou=student,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Domain Admins,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Domain Users,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Domain Guests,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Administrators,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Users,ou=group,dc=ldap,dc=hmes.kh.edu.tw                        新增的
adding new entry: cn=Guests,ou=group,dc=ldap,dc=hmes.kh.edu.tw                        新增的
adding new entry: cn=Power Users,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Account Operators,ou=group,dc=ldap,dc=hmes.kh.edu.tw        新增的
adding new entry: cn=Server Operators,ou=group,dc=ldap,dc=hmes.kh.edu.tw        新增的
adding new entry: cn=Print Operators,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Backup Operators,ou=group,dc=ldap,dc=hmes.kh.edu.tw        新增的
adding new entry: cn=Replicator,ou=group,dc=ldap,dc=hmes.kh.edu.tw                新增的
adding new entry: cn=Domain Computers,ou=group,dc=ldap,dc=hmes.kh.edu.tw        新增的
建samba trust machine account 標準程序
1]先用smbldap-useradd.pl -w [name]建立ldap名錄
2]在/etc/passwd 加入[name](可以用cp的,騙過 samba 就可以了但是name、uid 必須不能和別人相同)
3]用smbpasswd -a -m [name]補齊ldap samba.....的內容
(smbpasswd -a -m 不能自建ldap entry,必須先用smbldap-useradd.pl等來建,但smbldap-useradd.pl又沒有samba...等entry)
要這樣3個步驟根本就沒辦法作on-the-fly machine account 自動線上機器帳號,有沒有一個方法可以一次搞定呢?
-------------------------------------------------------------------------------------------------
修改smbldap-useradd.pl讓它建帳號時能自動加入sambaACCFlags,sambaSID,sambaLMPassword.........等entry內容
在smbldap-useradd.pl的第212~214行
#if (!add_samba_machine_mkntpwd($userName, $userUidNumber)) {
#          die "$0: error while adding samba accountn";
#        }
#  } else {
#        if (!add_samba_machine($userName)) {
#          die "$0: error while adding samba accountn";
#        }
的#註解拿掉就有了
     但還有sambaSID重複的問題
因為我的smbldap_conf.pm雖然設UID_START = 1000 可結果每次都是UID = name$
smbldap_tools.pm設定sambaSID = uid*2+1000 於是每次都是UID=3000 形成重複的窘境(會無法登入網域)

sambaSID = uidNumber * 2 + 1000
rid = 2*uidNumber+1000
primaryGroupID = 2*gidNumber+1001
如果每次建立account 時都指定 smbldap-useradd.pl -u 5566 [name] 就好了,但是線上自動建帳號不能這麼做
改用了smbldap-tools-0.8.4.tgz
smbldap-useradd -a [name] 第一次建帳號時不會,第二次以後建帳號會有:
User SID already owned by
uid=tester1,ou=student,dc=ldap,dc=hmes.kh.edu.tw
也因此在on-the-fly machine account 時也會把帳號的sambSID建得一樣(預設值SID-3000),
導致登入時sambaSID衝突。XP端顯示的訊息是:『嘗試加入網域"hmes7"時,發生以下錯誤:找不到使用者名稱』
當然,手動改一下sambaSID、改成和人家不一樣沒有重複的就可以了,可是自動建帳號時這可不成!!
檢查smbldap-useradd程式碼
第81行:
  # find first unused uid starting from $config{UID_START}
  while (defined(getpwuid($config{UID_START}))) {
        $config{UID_START}++;
也就是說(第525行):
The default is to use the smallest ID  value  greater than 1000 and greater than every other user.
但是,為什麼not work ?呢

網路上(國外)也有人試著
改寫smbldap-useradd的pl程式碼
內華達大學的做法是:讓XP的requires set an special registry entry to "0" (by default is set to "1").
這似乎是要讓 sambaSID(an special registry entry) 可以重複而不需要另行指定一個獨特的 sambaSID 給該機器
內華達大學是這麼做的:
    *  The Windows XP (and probably the W2K) requires set an special registry entry to "0" (by default is set to "1").
        This is documented in the samba/docs/Registry/WinXP_SignOrSeal.reg :
    ---
    ;
    ; This registry key (gathered from the Samba-tng lists) is needed
    ; for a Windows XP client to join and logon to a Samba domain
    ;
    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesnetlogonparameters
    "RequireSignOrSeal"=dword:00000000
    ---
(以上的東西,SAMBA官方已經寫成一個
註冊執行檔
(右鍵另存) (學校的機器是放在student的/usr/share/doc/samba-3.0.4/docs/registry/WinXP_SignOrSeal.reg)
,我們可以把它放在公用磁碟上,讓用戶端需要加入網域時先改機碼)
    As an alternative, Luke Howard  (9 Nov 2001), tell me:
    I noticed today that you can change this in the Local or Domain
    policy editor in Windows 2000, too.
    so, this should be the normal way:
      Local Security Settings
        Local Policies
          Security Options
            Domain member: Digitally encript ot sign secure channel data (always) -> DISABLE
    * Remember that you must provide an uidNumber=0 account when a W2K/XP joins to a domain.
    * If you change the registry entries, remember that several "CurrentControlSetServices*"
        may be present, and you should change all,
        or set (better) the policy that replaces all the entries with "0".
原始網頁在這裡
→修改smbldap-useradd程式碼(第256行)

update smbldap-tools-0.8.5
smbldap-useradd 沒有 sambaSamAccount objectclass
官方說法是:
The script defined with the add machine script must not add the sambaSAMAccount objectclass of the machine account.
The script must only add the Posix machine account.
Samba will add the sambaSamAccount when joining the domain.
在smb.conf中的smbldap-useradd -w只提供ldap簡易的加入名錄
待samba得到加入網域的 request 時才會加入sambaSamAccount objectclass,並順利讓機器加入網域
可是當samba 使用 smbpasswd -m 時又會找系統 /etc/passwd,如果發現裡面沒有這個人就不能添加 objectclass
於是 XP 用戶端就會出現"找不到使用者名稱"的這種錯誤???
安裝 perl-Crypt-SmbHash-0.02-8.i386.rpm
啟用 smbldap-useradd 的 use Crypt::SmbHash;
啟用 smbldap_tools.pm 的 use Crypt::SmbHash;
smbldap-useradd -i 【name】 :有sambaSamAccount objectclass,gidNumber是不正確的513(Domain Users)
smbldap-useradd -w【name】 :沒有sambaSamAccount objectclass(Posix stuff only),但gidNumber是正確的515(Domani Computers)
可見在安裝 perl-Crypt-SmbHash-0.02-8.i386.rpm 並啟用 use Crypt::SmbHash; 用smbldap-useradd -i 已可自建 sambaSamAccount Objectclass
【07/13】
在smbldap-tools 的 README 裡
The current release uses the "mkntpwd" program, in mkntpwd.tar.gz
in the current directory. It comes from
http://www.demog.berkeley.edu/~aperrin/tips/src/mkntpwd.tar.gz
It allows to not use smbpasswd (if $with_smbpasswd == 0 in smbldap_conf.pm)(應該是現在的smbldap.conf 裡的 with_smbpasswd="0")
如果單用 XP 用戶端、samba server 端 add machine script = smbldap-useradd -i  得到AcctFlags[i      ] 的sambaSamAccount objectclass
先用smbldap-useradd -i 【name】並輸入兩次密碼可以得到 sambaAcctFlags [DW      ] 的dn並順利讓 XP 加入網域
如果 samba server ,add machine script = smbldap-useradd -i  %u
XP 第一次要求加入網域時,smbldap-useradd 建立的 entry:
dn: uid=office47$, ou=machine, dc=ldap,dc=hmes.kh.edu.tw
sambaPrimaryGroupSID: S-1-5-21-3208428661-991213405-406351167-553
sambaLMPassword: AAD3B435B51404EEAAD3B435B51404EE
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: sambaSAMAccount
sambaLogonTime: 0
uid: office47$
uidNumber: 1013
cn: office47$
sambaLogoffTime: 2147483647
sambaPwdLastSet: 0
loginShell: /bin/false
sambaAcctFlags: [I          ]
gidNumber: 513
sambaPwdMustChange: 0
sambaSID: S-1-5-21-3208428661-991213405-406351167-3026
sambaNTPassword: 31D6CFE0D16AE931B73C59D7E0C089C0
sambaPwdCanChange: 0
description: Computer
homeDirectory: /dev/null
sambaKickoffTime: 2147483647
sn: office47$
samba server ,add machine script = smbldap-useradd -i  %u
XP 第二次要求加入網域時,smbldap-useradd 建立的 entry:
dn: uid=office47$, ou=machine, dc=ldap,dc=hmes.kh.edu.tw
sambaPrimaryGroupSID: S-1-5-21-3208428661-991213405-406351167-553
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: sambaSAMAccount
sambaLogonTime: 0
uid: office47$
uidNumber: 1013
cn: office47$
sambaLogoffTime: 2147483647
sambaPwdLastSet: 1089708946
loginShell: /bin/false
sambaAcctFlags: [DW         ]
gidNumber: 513
sambaPwdMustChange: 2147483647
sambaNTPassword: 923025FC7B21CB1A2037E7AC43F34823
sambaPwdCanChange: 1089708946
sambaSID: S-1-5-21-3208428661-991213405-406351167-3026
description: Computer
homeDirectory: /dev/null
sambaKickoffTime: 2147483647
sn: office47$
並順利登入網域
雖然可以了,但是想到要type兩次還是有些感覺滿瑕疵的
官方網站(samba.idealx.org)的解答是:
I want to create machine account on the fly, but it does not works or I must do it twice
    ◎ The script defined with the add machine script must not add the sambaSAMAccount objectclass of the machine account.
The script must only add the Posix machine account. Samba will add the sambaSAMAccount when joining the domain.
    ◎ Check that the add machine script is present in samba configuration file.
那當然還是得有mkntpasswd的協助,否則用smbpasswd會找/etc/passwd,找不到就不添加,不能讓機器加入,別說打兩遍,打一百遍也沒用。

手動增加使用者帳號
smbldap-useradd.pl -a -m -g teacher chen4802
smbldap-passwd.pl 【改帳號密碼】
思考!:
登入hmes1、hmes7網域因為sambaSID問題,都將造成用戶電腦不能同時供學生hmes7或老師hmes1使用
如果登入ldap會不會有更改密碼的問題:改了ldap密碼、mail系統密碼-郵件用、mail-samba密碼-分享資料夾用
XP的profile越來越大可需要另存?

手動增加使用者帳號,還有家目錄的問題:預設的家目錄是要在所登入的機器上(ldap),並存放XP漫遊(Roving)設定檔,如何將家目錄位置移轉到mail?

samba ldap 常用的名錄內容
Attribute         schema 來源                Usage
-----------------------------------------------------------------------------------------------------------
cn                 core         usually, the username
uid                  core         username
description         core         TODO
userPassword         core         password for Unix systems using NSS/PAM LDAP
displayName         inetorgperson         TODO
uidNumber         nis         the numeric user number (Unix and Samba)
gidNumber         nis         the primary group number of the user (Unix)
loginShell         nis         the logon shell used on Unix systems
gecos                  nis         the long form of the username 全名
homeDirectory         nis         home directory path for Unix systems
sambaPwdLastSet         samba         The integer time in seconds since 1970 when the lm and ntpasswd were last set.
sambaLogonTime                  samba         timestamp of last logon
sambaLogoffTime         samba         timestamp of last logoff
sambaKickoffTime         samba         timestamp of when the user will be logged off automatically
sambaPwdCanChange         samba         timestamp of when the user is allowed to update the password
sambaPwdMustChange         samba         timestamp of when the password will expire
sambaPwdLastSet         samba         timestamp of the last password update
sambaAcctFlags                  samba         specify the type of the samba account
sambaBadPasswordCount         samba         Bad password attempt count
sambaBadPasswordTime         samba         Time of the last bad password attempt (W=workstation, U=user, D=disabled,X=no password expiration,...)
sambaSID                  samba         the secure identifier (SID) of the user 不同的smbd有不同的SID,所以只能登入一個Samba
sambaPrimaryGroupID         samba         the relative identifier (SID) of the primary group of the user
sambaHomePath                  samba         specifies the path of the home directory for the user. The string can be null. If homeDrive is set and        specifies a drive letter, homeDirectory should be a UNC path. The path must be a network UNC path. This value can be a null string
sambaLogonScript         samba         The scriptPath property specifies the path of the user's logon script, .CMD, .EXE, or .BAT file.The string can be null. The path is relative to the netlogon share
sambaLMmPassword         samba         the LANMAN password
sambaNTPassword         samba         the NT password (md4 hash)(md5好像是單向加密,那md4可解嗎?)
sambaHomeDrive                  samba         specifies the drive letter to which to map the UNC path specified by homeDirectory. The drive letter must be specified in the form "driveletter:" where driveletter is the letter of the drive to map.For example: "Z:"
sambaProfilePath         samba         specifies a path to the user's profile. This value can be a null string, a local absolute path, or a UNC path

從/etc/samba/smbpasswd 複製密碼
cat mail.smbpasswd |grep f343
f343:2050:D670C67423644BD4AAD3B435B51404EE:6F93C3D6CDB5B248733C203E1293E222:[U          ]:LCT-3B8C877A:
(帳號:sambaLMPassword:sambaNTPassword:[旗標]:)
sambaLMPassword=D670C67423644BD4AAD3B435B51404EE
sambaNTPassword=6F93C3D6CDB5B248733C203E1293E222
還待解決的課題:
後端管理者介面php-web(可以讓電腦教室的老師,方便增刪修改學生帳號問題)
idxldapaccounts if you are looking for a nice Graphical User Interface
manager users account using the Microsoft Windows NT Domain management tools
system帳號和samba帳號密碼的同步 in ldap entry
guest帳號無密碼
bash "$PATH":/usr/local/sbin 和 ls 的顏色
【LDAP 常用的指令及工具】
=======================ldap server的工具=======================
ldapsearch 檢查entry ldapsearch -x -h 163.32.225.12 -b "dc=ldap,dc=hmes.kh.edu.tw"
ldapmodify 增刪改entry ldapmodify -x -D "cn=manager,dc=ldap,dc=hmes.kh.edu.tw" -w 密碼 -f tmp.ldif
可用以修改的ldif內
dn: ....................
新的entry................
ldapmodify   [-a]  [-b]  [-c]  [-r]  [-n]  [-v]  [-k]  [-d 除錯level]  [-D 綁dn]  [-W]  [-w 密碼] [-h ldaphost] [-p 埠號] [-f 檔名]
ldapadd [-b] [-c] [-r] [-n 只測不做] [-v]  [-k]  [-K]  [-d 除錯level]  [-D 綁dn]  [-w 密碼]  [-h ldaphost] [-p 埠號] [-f 檔名]
例如:ldapadd -x -D "cn=manager,dc=ldap,dc=hmes.kh.edu.tw" -f new.ldif -W
ldapdelete   [-n]   [-v]  [-k]  [-K]  [-c]  [-d 除錯level]  [-f 檔名]  [-D 綁dn]  [-W 提示密碼]  [-w 密碼] [-h ldaphost] [-p ldap埠] [dn]...
例如:ldapdelete -v 'cn=Rene van Leuken,o=TUDelft,c=NL' -D 'cn=Luiz Malere,o=TUDelft,c=NL' -W
=======================idealx公司的smbldap-tools工具=======================
smbldap-usershow 【name】查詢帳戶
smbldap-userdel 【name】刪除帳戶
smbldap-passwd 【name】修改用戶的密碼
●/usr/local/sbin/smbldap-useradd -a -m -g teacher -c "註解說明" 【name】新增帳戶
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
群晖 LDAP Samba 是指在群晖操作系统上使用LDAP作为身份验证机制,同时使用Samba来实现文件共享和打印服务。通过配置LDAPSamba,可以实现集中管理用户和权限,并提供安全可靠的文件共享和打印服务。 要在群晖上启用LDAPSamba,首先需要安装和配置LDAP服务器。然后,安装和配置Samba服务器,将其与LDAP集成。具体步骤如下: 1. 安装和配置LDAP服务器: a. 在群晖控制面板中,打开“用户和群组”。 b. 在“用户和群组”窗口中,选择“高级”选项卡,然后点击“LDAP”选项。 c. 启用LDAP服务器,并根据需要配置LDAP选项,例如基本DN、管理员DN和密码等。 d. 点击“应用”按钮保存更改。 2. 安装和配置Samba服务器: a. 在群晖控制面板中,打开“文件服务”。 b. 在“文件服务”窗口中,选择“Windows文件服务”选项,并点击“应用”按钮安装Samba服务器。 c. 在“文件服务”窗口中,选择“SMB / CIFS”选项,然后点击“编辑”按钮配置Samba服务器。 d. 在“编辑SMB / CIFS”窗口中,选择“高级设置”选项卡,并启用“启用LDAP用户和群组”选项。 e. 根据LDAP服务器的配置,输入LDAP服务器的地址、基本DN和管理员DN等信息。 f. 点击“应用”按钮保存更改。 通过以上步骤,你就可以在群晖上启用LDAPSamba,并实现集中管理用户和权限,同时提供文件共享和打印服务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值