描述
platform :ARM ,
compiler :xscale_be-gcc
Fllowing is my status report about Active Directory :
<1> for Samba Joining the windows2000 Domain with Active Directory
I have succeeded ,and test the result is ok
mainly steps is following :
kinit administrator@LINUX.SERCOMM.COM # get a ticket from a KDC of Windows2000 Server
/usr/local/samba/bin/net ads join # get the samba joined windows2000 Domain with Active Directory
/usr/local/samba/bin/net ads user # can get a user list of Windows2000 Server with Active Directory
throgh the steps ,the computers in the windows2000 domain can access the samba share resources ,not using input user name and password
Detailed infomation can be get from attachment 1 : How To combined Samba3.0 with Active Directory In Windows2000 Server.doc
===========================================
<2>How to put the authentication in NAS onto the windows2000 domain with Active Directory
for example , client willl access the ftp of NAS ,it will be authenticated by windows2000 domain controller with Active Directory
Now ,as far as I know , on the PC linux ,there is a mechanism called PAM(Pluggable Authentication Module) ,it supplies the uper application some uniform API ,such as function "pam_authenticate" ,"pam_start()" ,"pam_acct_mgmt()" ,etc. PAM has been used since Redhat 6.0 .PAM 就可以实现应用程序和authetication method 的分离, when a application want to change its authentication ,it doesn't need modify his code or re-compile his code . For example ,in our NAS , the bftpd Server source code .it also support PAM ,in login.c ,there is some code used to authenticate as followings :
其中加红色的都是PAM提供的标准的API,对于每个应用程序API都是一样的,只是对于不同的认证方式,具体的实现不一样而已。
下面是从bftpd 这个ftp server 的source code中摘出来的比较典型的一段:
int checkpass_pam(char *password)
{
struct pam_conv conv = { conv_func, password };
int retval = pam_start("bftpd", user, (struct pam_conv *) &conv, //pam_start()函数决定用哪种验证方式,这里的bftpd,对应的/etc/ pam.d/bftpd ,这个文件告诉代码,要用哪种身份验证方式
(pam_handle_t **) & pamh);
if (retval != PAM_SUCCESS) {
printf("Error while initializing PAM: %s\n",
pam_strerror(pamh, retval));
return 1;
}
pam_fail_delay(pamh, 0);
retval = pam_authenticate(pamh, 0); // /* 密码认证管理,检查用户输入的密码是否正确 */
if (retval == PAM_SUCCESS)
retval = pam_acct_mgmt(pamh, 0);// 通过了密码认证之后再调用帐户管理API,检查用户帐号是否已经过期
if (retval == PAM_SUCCESS)
pam_open_session(pamh, 0); //open 一个session
if (retval != PAM_SUCCESS)
return 1;
else
return 0;
}
PAM has implemented many authentication method ,for example : (getting from its source code)
======================================
pam_filter pam_mkhomedir pam_securetty pam_wheel
pam_ftp pam_motd pam_shells
pam_group pam_nologin pam_stress
pam_issue pam_permit pam_tally
pam_access pam_lastlog pam_pwdb pam_time
pam_cracklib pam_limits pam_radius(通过radius来进行身份验证) pam_unix (就是普通的验证/etc/passwd的方法)
pam_deny pam_listfile pam_rhosts pam_userdb
pam_env pam_mail pam_rootok pam_warn
======================================
比如对于ftp的程序,刚开始的时候想用pam_unix的方式来验证,
/etc/pam.d/ftp 这个文件就要写成这样:
#%PAM-1.0
auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
auth required /lib/security/pam_shells.so
auth required /lib/security/pam_unix.so (普通的验证/etc/passwd的方法)
auth sufficient /lib/pam_ldap.so (可以让LDAP Server来进行身份验证,也可以是windows2000 server 的Active Directory)
auth required /lib/security/pam_pwdb.so shadow nullok
account sufficient /lib/pam_ldap.so
account required /lib/security/pam_pwdb.so
session sufficient /lib/security/pam_ldap.so
#session required /lib/security/pam_pwdb.so
所以采用这种方式就非常的灵活,只要我们实现pam_ldap.so这个动态连接库就好了。
值得庆幸的是pam_ldap.so 已经早被实现了,see site: http://www.padl.com/OSS/pam_ldap.html ,its source code is pam_ldap.tar.gz ,
而且,很多应用程序里面都提供了对PAM的支持,包括bftpd ,samba,只不过samba的实现,相当在自己的code里面实现了PAM,但仍然提供了对PAM的支持,以保证通用性。当然samba的认证已经在最开始解决了,这里不考虑它,我们主要考虑的是ftp server ,telnet server ,ssh server,以及其他需要身份验证的server(条件是它的source code里面使用了PAM的标准的API)
利用pam_ldap.so这个module必须要用到或者有 选择 用到一下几种机制:
打开APP阅读更多精彩内容