0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LDAP 認証の技術検証:Active Directory と Windows Server での設定と確認をまとめた個人的な備忘録

Last updated at Posted at 2025-03-08

はじめに

Active Directory (AD) を使用した LDAP 認証の技術検証を行う。

本記事では、Windows Server 上で LDAP 認証をテストし、接続の確認方法やエラー発生時の対処方法について解説する。

環境情報

項目 設定値
LDAP サーバー (AD サーバー) ad.honda.com
LDAP ドメイン honda.com
LDAP ポート 389 (LDAP) または 636 (LDAPS)
テストユーザー testuser@honda.com
ユーザーの識別名 (DN) CN=testuser,CN=Users,DC=honda,DC=com

LDAP サーバーへの接続確認

LDAP サーバー (ad.honda.com) への接続が確立されていることを確認する。

Test-NetConnection を使用した確認

PowerShell で以下のコマンドを実行し、ポート 389 への接続が成功するか確認する。

Test-NetConnection -ComputerName ad.honda.com -Port 389

成功例:

ComputerName     : ad.honda.com
RemoteAddress    : 10.0.1.203
RemotePort       : 389
TcpTestSucceeded : True

失敗例:

TCP Test Failed

対処方法:

  • ad.honda.com が正しく名前解決できているか (nslookup ad.honda.com)
  • LDAP ポート (389 または 636) がファイアウォールで開放されているか確認

LDAP 認証のテスト

PowerShell を使った LDAP 認証

以下のスクリプトを PowerShell で実行し、testuser@honda.com の LDAP 認証をテストする。

$ldapServer = "ad.honda.com"
$ldapUser = "testuser@honda.com"
$ldapPassword = "P@ssw0rd"

try {
    $ldapConnection = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$ldapServer", $ldapUser, $ldapPassword)

    if ($ldapConnection.Name -ne $null) {
        Write-Host "LDAP 認証成功: ユーザー $ldapUser は有効"
    } else {
        Write-Host "LDAP 認証失敗: ユーザーが見つからない"
    }
} catch {
    Write-Host "LDAP 認証エラー: $_"
}

成功時:

LDAP 認証成功: ユーザー testuser@honda.com は有効

失敗時:

LDAP 認証失敗: ユーザーが見つからない
LDAP 認証エラー: Access is denied

対処方法:

  • testuser@honda.com のパスワードが正しいか確認
  • Get-ADUser コマンドでユーザーの識別名 (DN) を取得
Get-ADUser -Filter {SamAccountName -eq "testuser"} | Select-Object DistinguishedName

GUI ツール ldp.exe を使用した認証テスト

  • Windowsキー + R を押して ldp.exe を開く
  • 「Connection」→「Connect」 を選択
    • Server: ad.honda.com
    • Port: 389(LDAPS を使う場合は 636
    • Use SSLチェックなし(LDAPS 使用時はチェック)
  • 「Connection」→「Bind」 を選択
    • Bind Type: Simple Bind
    • User: testuser@honda.com
    • Password: P@ssw0rd
  • 「OK」をクリックして認証を試す
    • 認証成功時: Authenticated as DN のメッセージが表示
    • 認証失敗時: Invalid credentials エラーが表示

ldapsearch コマンドを使用した認証テスト

Linux (WSL) 環境から LDAP 認証をテストする場合、以下のコマンドを実行する。

ldapsearch -x -H ldap://ad.honda.com -D "CN=testuser,CN=Users,DC=honda,DC=com" -W -b "DC=honda,DC=com"

成功時:

dn: CN=testuser,CN=Users,DC=honda,DC=com
objectClass: user
sAMAccountName: testuser

失敗時:

ldap_bind: Invalid credentials (49)

対処方法:

  • パスワードが正しいか確認
  • ユーザーの DN (識別名) を Get-ADUser で確認

まとめ

方法 確認内容 コマンド
PowerShell を使用 testuser@honda.com が LDAP 認証できるか PowerShell スクリプト
ldp.exe を使用 GUI で LDAP 認証を試す ldp.exe
ldapsearch を使用 Linux (WSL) から認証 ldapsearch
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?