LDAP 搬家後記:一個工程師的創傷後應激與 Docker 化決心
Linux

LDAP 搬家後記:一個工程師的創傷後應激與 Docker 化決心

2026-03-14 · 9 分鐘 · Ray Lee (System Analyst)

上一篇,我寫了一場搬遷。476 條靈魂,從一台老伺服器,搬進另一台老伺服器。Schema 地獄三連王、DN 大小寫陷阱、還有那個永遠記不住的 ldapmodify 語法。如果你還沒讀過,請先備好胃藥再點這裡

這篇,是後記。

搬完的那一刻

搬遷成功的那個瞬間,我什麼都沒感覺到。

沒有煙火,沒有啤酒,沒有同事衝過來拍我的肩膀說「幹得好」。只有我一個人,凌晨三點,盯著終端機上的 ldapsearch 回傳了 476 筆結果,然後緩緩地把筆電闔上。

那種感覺不是成就感,是倖存者的空虛。像是打完 Schema 地獄三連 Boss 之後,發現背包裡的補血藥全用光了,而且存檔點在三小時前。

我躺在床上,盯著天花板想了一件事:如果明年又要搬呢?如果客戶也要搬呢?如果有人問我「你可以教我嗎」,我要從哪裡開始教?從 slapd.confcn=config 的世紀之爭開始嗎?

「這種工作,做一次是英雄,做第二次是傻子。」

問題的根源

LDAP 的問題從來不是 LDAP 本身。LDAP 是一個完全合格的目錄服務協定,它只是假設使用它的人都有博士學位。

痛點一:沒有 UI。想看目錄結構?請下 ldapsearch。想改一個人的電話號碼?請寫一個 LDIF 檔案,確保你的空行在正確的位置,然後用 ldapmodify 送進去,再用 ldapsearch 確認你沒有把整個 OU 炸掉。恭喜你,你剛花了十五分鐘做了一件在任何正常系統裡只需要點兩下滑鼠的事。

痛點二:沒有 API。想讓你的應用程式自動建立使用者帳號?歡迎來到「用程式產生 LDIF 然後 shell exec ldapadd」的黑暗時代。你以為 2026 年了大家都在用 REST API?LDAP 的世界還停留在「TCP 389 上面跑二進位協定」的美好年代。

痛點三:知識不會累積。每次搬遷都是一次全新的冒險,因為上次搬遷的筆記寫在某個 wiki 頁面的角落,而那個 wiki 已經被 IT 部門砍掉了。LDAP 的知識存在個人的腦袋裡,而個人會離職、會忘記、會在凌晨三點做出錯誤的決定。

「市場上沒有這個東西,不是因為需求不存在,是因為寫這個的人都在用命令列假裝很酷。」

所以我做了一個盒子

三個月後,我做了一個決定。

不是「下次搬遷要寫更好的筆記」這種自我欺騙式的決定。是「我要把這整件事裝進一個 Docker Compose 檔案,讓任何人都能在五分鐘內擁有一個完整的 LDAP 服務」的那種決定。

所以我做了一個盒子。

docker compose up,五分鐘,LDAP 就位。 OpenLDAP 跑起來了。TLS 設定好了。管理員帳號建好了。你不需要知道 slapd 是什麼,你不需要知道 cn=configslapd.conf 的差別,你只需要知道 docker compose up

Web UI,不用背指令。 想看目錄?打開瀏覽器。想改資料?點兩下。想加一個使用者?填表單。就像一個正常的、屬於 2026 年的管理介面。那些 ldapsearch -x -H ldap://localhost -b "dc=example,dc=com" -D "cn=admin,dc=example,dc=com" -W 的日子,結束了。

REST API,不再是孤島。 你的應用程式想建立使用者?POST 一個 JSON。想查詢群組成員?GET 一個 endpoint。LDAP 終於可以跟你的其他系統正常對話了,而不是躲在 389 port 後面假裝自己是 1993 年的產品。

盒子在這裡:github.com/ray-idempiere/ldap-in-a-box

LDAP-in-a-Box Web UI

太史公曰

太史公曰:昔有蒜頭君,夜遷四百七十六魂於新域,歷 Schema 煉獄而不死,遂悟一理——凡痛苦重複二次以上者,皆可封箱。乃鑄「盒中之盒」,以 Docker 為殼、OpenLDAP 為骨、Web UI 為面、REST API 為口,使後來者免於命令列之苦。

嗚呼,天下苦 LDAP 久矣。今有此盒,五分鐘可得目錄服務,不必再背 ldapmodify 之咒語。善哉。

開箱請至:github.com/ray-idempiere/ldap-in-a-box

English

Last time, I wrote about a migration. 476 souls, dragged from one aging server to another. Schema Hell’s triple boss fight, the DN case-sensitivity trap, and that ldapmodify syntax I will never, ever memorize. If you missed it, grab some antacid and click here.

This is the epilogue.

The Moment After

The instant the migration succeeded, I felt nothing.

No fireworks. No beer. No colleague rushing over to slap my back and say “great job.” Just me, alone at 3 AM, staring at a terminal where ldapsearch had returned exactly 476 results. I slowly closed my laptop.

It wasn’t pride. It was the hollow emptiness of a survivor. Like finishing the Schema Hell triple boss fight only to realize your health potions are gone and your last save point was three hours ago.

Lying in bed, staring at the ceiling, one thought kept circling: what if I have to do this again next year? What if a client needs to migrate? What if someone asks me to teach them — where do I even start? The century-long war between slapd.conf and cn=config?

“Do this once, you’re a hero. Do it twice, you’re a fool.”

The Root Cause

The problem with LDAP was never LDAP itself. LDAP is a perfectly competent directory protocol. It simply assumes everyone using it has a PhD.

Pain point one: no UI. Want to browse the directory? Fire up ldapsearch. Want to change someone’s phone number? Write an LDIF file, make sure your blank lines are in exactly the right places, pipe it through ldapmodify, then run ldapsearch again to confirm you didn’t just nuke an entire OU. Congratulations, you just spent fifteen minutes doing something that takes two clicks in any sane system.

Pain point two: no API. Want your app to auto-provision user accounts? Welcome to the dark ages of “generate LDIF strings in code and shell-exec ldapadd.” You thought everyone was using REST APIs in 2026? LDAP’s world is still partying like it’s 1993, running a binary protocol on TCP 389.

Pain point three: knowledge doesn’t accumulate. Every migration is a fresh adventure because your notes from last time are buried in a wiki page that IT already decommissioned. LDAP expertise lives in individual brains, and individuals quit, forget, and make terrible decisions at 3 AM.

The reason nobody had built a proper solution wasn’t that the need didn’t exist. It’s that everyone who understood the problem was too busy looking cool in a terminal.

So I Built a Box

Three months later, I made a decision.

Not the “I’ll write better notes next time” kind of decision — that’s just lying to your future self. The “I’m going to put this entire mess into a Docker Compose file so anyone can have a working LDAP service in five minutes” kind.

So I built a box.

docker compose up — five minutes — LDAP ready. OpenLDAP running. TLS configured. Admin account created. You don’t need to know what slapd is. You don’t need to know the difference between cn=config and slapd.conf. You just need to know docker compose up.

Web UI — no commands to memorize. Want to browse the directory? Open a browser. Want to edit an entry? Click twice. Want to add a user? Fill out a form. Like a normal, 2026-era admin interface. The days of ldapsearch -x -H ldap://localhost -b "dc=example,dc=com" -D "cn=admin,dc=example,dc=com" -W are over.

REST API — no more LDAP island. Your app needs to create a user? POST some JSON. Need group membership? GET an endpoint. LDAP can finally talk to your other systems like a normal service, instead of hiding behind port 389 pretending it’s still 1993.

The box is here: github.com/ray-idempiere/ldap-in-a-box

LDAP-in-a-Box Web UI

The Historian Writes

太史公曰 (The Historian writes): In days of old, the Garlic Knight migrated 476 souls into a new domain by night, surviving the Schema Inferno through sheer stubbornness. From this ordeal came a revelation — any suffering repeated more than once deserves to be boxed. And so the Box was forged: Docker for the shell, OpenLDAP for the bones, a Web UI for the face, and a REST API for the voice, that those who come after might be spared the incantations of the command line.

Alas, the world has suffered under LDAP long enough. Now there is a box. Five minutes to a working directory service. No ldapmodify spells required. And it is good.

Unbox it here: github.com/ray-idempiere/ldap-in-a-box

日本語

前回、ある引越しの話を書いた。476人の魂を、古びたサーバーから別の古びたサーバーへ運ぶ話。Schema地獄の三連ボス戦、DNの大文字小文字トラップ、そして一生覚えられない ldapmodify の構文。まだ読んでいない方は、胃薬を用意してからこちらへ

これは、その後日談である。

引越し完了の瞬間

移行が成功した瞬間、何も感じなかった。

花火もない。ビールもない。同僚が駆け寄ってきて「お疲れ様」と肩を叩いてくれることもない。午前3時、ターミナルに ldapsearch が476件の結果を返すのを見つめ、静かにノートPCを閉じた。それだけだった。

達成感ではなかった。生存者の虚無感だった。Schema地獄の三連ボスを倒した後、回復アイテムが全部なくなっていて、最後のセーブポイントが3時間前だったと気づいた時の、あの感覚。

ベッドに横たわり、天井を見つめながら一つのことが頭を離れなかった。来年もまた引越しがあったら?クライアントの移行を頼まれたら?「教えてください」と言われたら、どこから教える?slapd.confcn=config の百年戦争からか?

「一度やれば英雄、二度やれば馬鹿。」

問題の根源

LDAPの問題はLDAP自体ではない。LDAPは完全に有能なディレクトリプロトコルだ。ただ、使う人間が全員博士号を持っていることを前提にしているだけで。

苦痛その一:UIがない。 ディレクトリを見たい?ldapsearch を叩け。誰かの電話番号を変えたい?LDIFファイルを書いて、空行の位置が正確であることを確認して、ldapmodify で流し込んで、ldapsearch でOU全体を吹き飛ばしていないことを祈れ。おめでとう、まともなシステムなら2クリックで終わることに15分かけた。

苦痛その二:APIがない。 アプリから自動でユーザーアカウントを作りたい?「コードでLDIF文字列を生成して ldapadd をシェル実行する」という暗黒時代へようこそ。2026年なのにREST APIすら使えない?LDAPの世界はまだ1993年、TCP 389でバイナリプロトコルを走らせていた時代を謳歌している。

苦痛その三:知識が蓄積されない。 毎回の移行が新しい冒険になる。前回のメモはどこかのWikiページの片隅にあったはずだが、そのWikiはIT部門にもう消された。LDAPの知識は個人の頭の中にあり、個人は退職し、忘れ、午前3時に間違った判断をする。

市場にこういうものがなかったのは、需要がなかったからではない。この問題を理解している人間が全員、ターミナルでカッコつけるのに忙しかったからだ。

だから箱を作った

3ヶ月後、ある決断をした。

「次はもっと良いメモを書こう」という自己欺瞞的な決断ではない。「このめちゃくちゃな作業を丸ごとDocker Composeファイルに詰め込んで、誰でも5分で完全なLDAPサービスを手に入れられるようにする」という決断だ。

だから、箱を作った。

docker compose up、5分、LDAP完成。 OpenLDAPが起動する。TLSが設定される。管理者アカウントが作られる。slapd が何かを知る必要はない。cn=configslapd.conf の違いを知る必要もない。docker compose up だけ知っていればいい。

Web UI、コマンドを覚える必要なし。 ディレクトリを見たい?ブラウザを開け。データを編集したい?2回クリック。ユーザーを追加したい?フォームに記入。2026年にふさわしい、普通の管理画面。あの ldapsearch -x -H ldap://localhost -b "dc=example,dc=com" -D "cn=admin,dc=example,dc=com" -W の日々は、終わった。

REST API、もう孤島じゃない。 アプリからユーザーを作りたい?JSONをPOST。グループメンバーを確認したい?エンドポイントにGET。LDAPはついに他のシステムとまともに会話できるようになった。ポート389の裏に隠れて1993年のふりをする必要は、もうない。

箱はここにある:github.com/ray-idempiere/ldap-in-a-box

LDAP-in-a-Box Web UI

太史公いわく

太史公いわく——昔、ニンニク侍ありて、夜に476人の魂を新たなる領域へ移し、Schema煉獄を生き延びたり。その苦難より一つの悟りを得る。すなわち、二度以上繰り返される苦痛は、すべて箱に封じるべし、と。かくして「箱」は鍛造された。Dockerを殻とし、OpenLDAPを骨とし、Web UIを顔とし、REST APIを口とし、後に続く者がコマンドラインの呪文から解放されんことを願って。

嗚呼、天下LDAPに苦しむこと久し。今この箱あり、5分にしてディレクトリサービスを得る。ldapmodify の呪文を唱える必要はもうない。善きかな。

開封はこちら:github.com/ray-idempiere/ldap-in-a-box

Ray Lee (System Analyst)
作者 Ray Lee (System Analyst)

iDempeire ERP Contributor, 經濟部中小企業處財務管理顧問 李寶瑞