DEV Community

Ali Orhun Akkirman for Açıklab

Posted on • Edited on

7

LDAP Proxy Sunucu Kurulumu

Çeşitli koşullarda LDAP Proxy ihtiyacı duyulabilir. Bu gibi durumlar için OpenLDAP'ı kullanabiliriz. Arkaplanda MS Aktif Dizin veya SAMBA DC olması herhangi bir fark oluşturmamakta. Tabi ki en önemli nokta adreslenecek niteliği belirlemek olacaktır.

Örneğimizde 389 portu üzerinden LDAP proxy yapmak olduğu için aşağıdaki paketleri kurmanız gerekmektedir. Bu çalışma için Pardus 19.x Sunucu sürümü kullanılmıştır.

apt install slapd ldap-utils -y
Enter fullscreen mode Exit fullscreen mode

Paketleri kurduktan sonra adresinde aşağıdaki dosya içeriğine göre /etc/ldap/slapd.conf isminde bir dosya oluşturmanız gerekmektedir. Bu dosyada ADveyaSAMBAIP yerine LDAP kaynağınızın IP veya FQDN adresi, dc=acik,dc=lab yerine ise kendi Temel DN adresinizi yazmanız gerekmektedir.

### Schemas ###########################################################
include         /etc/ldap/schema/core.schema
include         /etc/ldap/schema/cosine.schema
include         /etc/ldap/schema/nis.schema
include         /etc/ldap/schema/inetorgperson.schema

## Modules ##############################################################
moduleload              back_ldap.la
moduleload              rwm

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

### Database definition (Proxy to AD) #########################################
database                ldap
readonly                yes
protocol-version        3
rebind-as-user
uri                     "ldap://ADveyaSAMBAIP:389"
suffix                  "dc=acik,dc=lab"
overlay                 rwm
rwm-map                 attribute       uid     sAMAccountName
rwm-map                 attribute       mail    proxyAddresses

### Logging ###################################################################
loglevel                0
Enter fullscreen mode Exit fullscreen mode

Bu işlemi yaptıktan sonra dosyada herhangi bir sorun olup olmadığına dair kontrol için aşağıdaki komutu çalıştırabilirsiniz. İlgili komutta çeşitli uyarılar (warnings) olabilir. Bunlar önemli değil ama "config file testing succeeded" mesajını gördüyseniz herhangi bir problem yok.

slaptest -f /etc/ldap/slapd.conf
Enter fullscreen mode Exit fullscreen mode

Komut çıktısında " PROXIED attributeDescription "SAMACCOUNTNAME" inserted." ve " PROXIED attributeDescription "PROXYADDRESSES" inserted." gibi iki uyarı göreceksiniz. Normal şartlarda bu pek önemli olmasa da, çözüm için aşağıdaki şema tanımını OpenLDAP şemasına eklemeniz gerekmektedir.

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

 attributetype ( 1.2.840.113556.1.2.210
       NAME 'proxyAddresses'
       SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' )
Enter fullscreen mode Exit fullscreen mode

Bu adımda /etc/default/slapd dosyasının ilk satırlarında yer alan SLAPD_CONF satırını aşağıdaki içerik ile değiştirmeniz gerekmekte.

SLAPD_CONF=/etc/ldap/slapd.conf
Enter fullscreen mode Exit fullscreen mode

İlgili ayarı yaptıktan sonra slapd servisini yeniden başlatmanız yeterlidir.

systemctl restart slapd
Enter fullscreen mode Exit fullscreen mode

Artık Test için OpenLDAP sunucusunda localhost olarak veya uzak bir sunucuda OpenLDAP sunucusu adresini yazarak aşağıdaki komutun çıktı verdiğini görmeniz gerekmektedir. Tabi ki gerekli giriş bilgilerini ve Temel DN bilgilerini de yazmanız gerekmektedir:

ldapsearch -h localhost -x -LLL -D "cn=administrator,cn=users,dc=acik,dc=lab" -b "cn=users,dc=acik,dc=lab" -w "ParolaGir" "(cn=Administrator)" name
Enter fullscreen mode Exit fullscreen mode

Eğer geri dönüş olarak hata vermek yerine dn ve name bilgileri geldi ise Vekil işlemi gerçekleşmiştir. Kendi testlerinizi de yapabilirsiniz.

Mandatum morte dissolvitur

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay