moodle + openLDAP

姜天宇
2023-12-01


1.安装OpenLDAP(openldap-2.2.29-db-4.3.29-openssl-0.9.8a-win32_Setup.exe)
  使用默认设置安装

2.更改配置slapd.conf
 suffix  "dc=my-domain,dc=com"
 rootdn  "cn=Manager,dc=my-domain,dc=com"
 rootpw  secret

 按照猫增加相应的shema文件

include         ./schema/core.schema
include         ./schema/cosine.schema
include         ./schema/nis.schema
include         ./schema/inetorgperson.schema

3.运行:ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
  要是返回类似以下信息,那恭喜你,openldap就安装成功了.
  dn:
  namingContexts: dc=example,dc=com.

3.添加LDIF entries:

LDIF 文件格式如下:
 example.ldif文件:
 ## Organization for Example Corporation
 #dn: dc=my-domain,dc=com
 #objectClass: dcObject
 #objectClass: organization
 #dc: my-domain
 #o: Example Corporation
 #description: The Example Corporation


 #first.ldif
 # Organizational Role for Directory Manager
 dn: cn=Manager,dc=example,dc=com
 o: exampleCompany
 dc: example
 objectclass: dcObject
 objectclass: organization
 objectClass: organizationalRole
 cn: Manager
 description: Directory Manager

 通过ladpadd.exe添加,用法见4

 
 ## person for exmple corporation
 #dn: uid=person,dc=cluster,dc=com
 #uid: person
 #cn: Person
 #objectClass: account
 #objectClass: posixAccount
 #objectClass: top
 #objectClass: shadowAccount
 #userPassword:123

 #second.ldif
 #add user
 dn: cn=testUser,dc=example,dc=com
 cn: testUser
 sn: testUser
 objectClass: top
 objectClass: person
 objectClass: inetOrgPerson
 objectClass: qmailUser
 uid: test
 userPassword: test

 通过ladpadd.exe添加,用法见4


4.运行ldapadd.exe -x -D "cn=Manager,dc=my-domain,dc=com" -W -f example.ldif
 按提示输入Manager的密码

5.测试LDAP:
 1)ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
 2)用LDAPBrowser查看是否已添加

6.删除用户,
    example:
 ldapdelete -x -D'cn=Manager,dc=my-domain,dc=com' -w secret "cn=testUser,dc=longshine,dc=com"

referrence :http://www.openldap.org/doc/admin/quickstart.html

 

moodle中LDAP authentication configureration

1.以管理员身份登录
2.进入yourhomesite -> Administration -> Users -> Authentication options
3.Choose an authentication method:LDAP
  then you can see:Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled.
4.config  php.ini
  loadLADP_Module methoed: delete comment ;extension=php_ldap.dll
5.LDAP服务器设置 :
  ldap_host_url:ldap://主机:端口  如:ldap://192.168.0.100:389(default LDAP port)
  ldap_version:3
  ldap_user_type:posixAccount(rfc2307)
  ldap_contexts::‘dc=example,dc=com’
  ldap_search_sub:yes
  ldap_user_attribute:uid

  其它没有列出的选项可以不填或是按说明填写即可。

referrence :http://docs.moodle.org/en/LDAP_authentication

 

 

 类似资料: