如何使用 SSL 配置 OpenLDAP 作为使用 LDIF 方法的 Active Directory 代理

问题描述 投票:0回答:1

在我的公司,我们有一个 Active Directory 来管理用户,还有许多办公室外的 Web 服务,我们希望他们的登录系统通过 ldap 来完成。我想通过 SSL 发布 LDAP 并使所有这些 Web 服务登录到我们的 AD,但我不想公开 AD,甚至不通过 SSL,所以我想在我们的 DMZ 中设置一个到 AD 的 OpenLDAP 代理并连接以只读模式写入 AD。我根本不是 LDAP 专家,当我过去设置其他 LDAP 时,我按照几个步骤运行一个 LDAP,然后使用 Apache Directory Studio 或 LAM 管理它们,我预计这会更容易完成好吧,这似乎比我预想的更难完成。

我已经处理这个问题好几个星期了,但我找不到任何方法来完成它。每个人都说 slapd.conf 已被弃用,并且必须不再使用,并且有很多关于如何通过 LDIF 使用 SSL 配置 OpenLDAP 的教程,但我找不到任何方法来配置,通过 LDIF 和 ssl 的 openldap AD 的代理。我能找到将 LDAP 配置为 AD 代理的唯一方法是在 samba 站点上使用此 slapd.conf 文件

### Schema includes ###########################################################
include                 /etc/openldap/schema/core.schema
include                 /etc/openldap/schema/cosine.schema
include                 /etc/openldap/schema/inetorgperson.schema
include                 /etc/openldap/schema/misc.schema
include                 /etc/openldap/schema/nis.schema

## Module paths ##############################################################
modulepath              /usr/lib64/openldap/
moduleload              back_ldap
moduleload              rwm

# Main settings ###############################################################
pidfile                 /var/run/openldap/slapd.pid
argsfile                /var/run/openldap/slapd.args

### Database definition (Proxy to AD) #########################################
database                ldap
readonly                yes
protocol-version        3
rebind-as-user
uri                     "ldap://{AD-Hostname/IP}:389"
suffix                  "{your Domain DN}"
overlay                 rwm
rwm-map                 attribute       uid     sAMAccountName

### Logging ###################################################################
loglevel                0

我还修改了

schemas/inetorgperson.schema
,并添加了这个

################
#AD schema
################
attributetype ( 1.2.840.113556.1.4.221
      NAME 'sAMAccountName'
      SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )
################

最后,通过添加

schemas/inetorgperson.ldif

上添加 sAMAccountName 属性
olcAttributeTypes: ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )

olcObjectClasses: ( 2.16.840.1.113730.3.2.2 NAME 'inetOrgPerson' DESC 'RFC2
798: Internet Organizational Person' SUP organizationalPerson STRUCTURAL MAY
( audio $ businessCategory $ carLicense $ departmentNumber $ displayName $ em
ployeeNumber $ employeeType $ givenName $ homePhone $ homePostalAddress $ ini
tials $ jpegPhoto $ labeledURI $ mail $ manager $ mobile $ o $ pager $ photo
$ roomNumber $ secretary $ uid $ userCertificate $ x500uniqueIdentifier $ pre
ferredLanguage $ userSMIMECertificate $ sAMAccountName $ userPKCS12i ) )

它起作用了,但是在删除目录

slapd.d
并使用

重新创建它之后
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d

(然后应用适当的所有权)。

显然,当我这样做时,我之前使用 LDIF 的配置 - 创建本地数据库并设置 SSL - 被删除了,并且由于我使用了 slapd.conf 并创建了 sladp.d 目录,我的 ldap 管理员帐户也被删除了,并且我无法再次配置 SSL 或添加更多数据库。

首先,我按照这些步骤配置了本地数据库并配置了 SSL。

[root@dlp ~]# systemctl enable --now slapd 

# generate encrypted password
[root@dlp ~]# slappasswd

New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@dlp ~]# vi chrootpw.ldif
# specify the password generated above for [olcRootPW] section

dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx

[root@dlp ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"

导入基本架构

[root@dlp ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=cosine,cn=schema,cn=config"

[root@dlp ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=nis,cn=schema,cn=config"

[root@dlp ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=inetorgperson,cn=schema,cn=config"

在 LDAP DB 上设置域名。

 # generate directory manager's password

[root@dlp ~]# slappasswd

New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@dlp ~]# vi chdomain.ldif
# replace to your own domain name for [dc=***,dc=***] section
# specify the password generated above for [olcRootPW] section

dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
  read by dn.base="cn=Manager,dc=domain,dc=int" read by * none

dn: olcDatabase={2}mdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=domain,dc=int

dn: olcDatabase={2}mdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=domain,dc=int

dn: olcDatabase={2}mdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx

dn: olcDatabase={2}mdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
  dn="cn=Manager,dc=domain,dc=int" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=domain,dc=int" write by * read

[root@dlp ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}monitor,cn=config"

modifying entry "olcDatabase={2}mdb,cn=config"

modifying entry "olcDatabase={2}mdb,cn=config"

modifying entry "olcDatabase={2}mdb,cn=config"

modifying entry "olcDatabase={2}mdb,cn=config"

[root@dlp ~]# vi basedomain.ldif
# replace to your own domain name for [dc=***,dc=***] section

dn: dc=domain,dc=int
objectClass: top
objectClass: dcObject
objectclass: organization
o: LDAP Server
dc: domain

dn: cn=Manager,dc=domain,dc=int
objectClass: organizationalRole
cn: Manager
description: Directory Manager

dn: ou=People,dc=domain,dc=int
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=domain,dc=int
objectClass: organizationalUnit
ou: Group

[root@dlp ~]# ldapadd -x -D cn=Manager,dc=domain,dc=int -W -f basedomain.ldif

Enter LDAP Password:     # directory manager's password

adding new entry "dc=domain,dc=int"

adding new entry "cn=Manager,dc=domain,dc=int"

adding new entry "ou=People,dc=domain,dc=int"

adding new entry "ou=Group,dc=domain,dc=int"

生成CA和有效证书后

 [root@dlp ~]# cp /etc/pki/tls/certs/{server.key,server.crt} /etc/openldap/certs/

[root@dlp ~]# chown ldap:ldap /etc/openldap/certs/{server.key,server.crt}
[root@dlp ~]# vi mod_ssl.ldif
# create new

dn: cn=config
changetype: modify
replace: olcTLSCertificateFile
olcTLSCertificateFile: /etc/openldap/certs/server.crt
-
replace: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/openldap/certs/server.key

[root@dlp ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f mod_ssl.ldif

SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "cn=config"

[root@dlp ~]# systemctl restart slapd 

并允许防火墙

 [root@dlp ~]# firewall-cmd --add-service={ldap,ldaps}

success
[root@dlp ~]# firewall-cmd --runtime-to-permanent

success 

这有效,它留下了一个带有 DIT 的工作 LDAPS 服务器

dc=domain,dc=int
,我可以与我的用户
cn=Manager,dc=domain,dc=int
连接,创建任何对象,等等。

但是由于我找不到任何方法来配置它以使用以前的配置添加另一个数据库,我不得不删除 slapd.d 目录,创建一个 slapd.conf 文件并应用它,所以它生成了一个全新的 slapd。 d 目录,仅包含 AD 代理,没有 SSL,也没有用户可以进行诸如应用更多 LDIF 之类的操作。

所以,我需要知道如何将它们混合在一起。

centos ldap debian openldap ldif
1个回答
0
投票

Hola 作为 podido 解决者问题?哟 estoy en la Misma pero no pude 解析器,探针 con docker db meta 等 de mil maneras y sigo sin lograrlo。

Beuno si tiene info te agrdeceria una mano。

致敬

纳韦尔

© www.soinside.com 2019 - 2024. All rights reserved.