Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
Node.js 드라이버
/ /

LDAP (PLAIN) 인증 메커니즘

PLAIN 인증 메커니즘 사용하면 LDAP(Lightweight Directory Access Protocol) 사용자 이름 과 비밀번호를 사용하여 MongoDB 에 인증할 수 있습니다. LDAP 인증 RFC- 에 정의된 PLAIN 단순 인증 및 보안4616 계층(SASL)을 사용합니다.

이 메커니즘은 MongoDB Atlas 또는 MongoDB Enterprise Advanced 에 인증할 때만 사용할 수 있습니다.

이 페이지의 코드 예제에서는 다음 자리 표시자를 사용합니다.

  • <ldap_username>: LDAP 사용자 이름 입니다.

  • <ldap_password>: LDAP 비밀번호입니다.

  • <cluster_url>: MongoDB deployment 의 네트워크 주소 .

코드 예제를 사용하려면 이러한 자리 표시자를 원하는 값으로 바꾸세요.

PLAIN 인증 메커니즘 사용자 이름 과 비밀번호를 사용하여 LDAP 서버 에 인증합니다.

다음 샘플 코드와 authMechanism 같이 매개 변수를 로 설정하고 PLAIN LDAP 연결 에 string 사용자 이름 및 비밀번호를 포함하여 이 인증 메커니즘을 지정할 수 있습니다.

const { MongoClient } = require("mongodb");
// specify the placeholder values for your environment in the following lines
const clusterUrl = "<cluster_url>";
const ldapUsername = "<ldap_username>";
const ldapPassword = "<ldap_password>";
const authMechanism = "PLAIN";
// Connection URI
const uri = `mongodb+srv://${ldapUsername}:${ldapPassword}@${clusterUrl}/?authMechanism=${authMechanism}`;
const client = new MongoClient(uri);
// Function to connect to the server
async function run() {
try {
// Establish and verify connection
await client.db("admin").command({ ping: 1 });
console.log("Connected successfully to server");
} finally {
// Ensures that the client will close when you finish/error
await client.close();
}
}
run().catch(console.dir);

이 페이지에서 설명하는 메서드 또는 유형에 대해 자세히 학습 다음 API 설명서를 참조하세요.

돌아가기

OIDC

이 페이지의 내용