AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

db.getUser() (mongosh 메서드)

db.getUser(username, args)

Returns user information for a specified user. Run this method on the user's database. If the user doesn't exist in the database, db.getUser() returns null.

The db.getUser() method has the following parameters:

db.getUser( "<username>", {
showCredentials: <Boolean>,
showCustomData: <Boolean>,
showPrivileges: <Boolean>,
showAuthenticationRestrictions: <Boolean>,
filter: <document>
} )
Parameter
유형
설명

username

문자열

정보를 검색할 사용자의 이름입니다.

args

문서

선택 사항입니다. 추가 인수를 지정하는 문서입니다.

args 문서는 다음 필드를 지원합니다.

필드
유형
설명

showCredentials

부울

선택 사항입니다. 사용자의 비밀번호 해시를 표시하려면 true로 설정합니다.

기본적으로 이 필드는 false입니다.

showCustomData

부울

선택 사항입니다. 출력에서 사용자의 customData를 생략하려면 false로 설정합니다.

기본적으로 이 필드는 true입니다.

버전 5.2에 추가 되었습니다.

showPrivileges

부울

선택 사항입니다. 상속된 역할에 대한 확장된 정보를 포함하여 사용자의 전체 권한 세트를 표시하려면 true 로 설정합니다.

기본적으로 이 필드는 false입니다.

모든 사용자를 보는 경우에는 이 필드를 지정할 수 없습니다.

showAuthenticationRestrictions

부울

선택 사항입니다. 사용자의 인증 제한을 표시하려면 true로 설정합니다.

기본적으로 이 필드는 false입니다.

모든 사용자를 보는 경우에는 이 필드를 지정할 수 없습니다.

filter

문서

선택 사항입니다. 필터 조건과 일치하는 사용자에 대한 정보를 반환하기 위해 $match 단계 조건을 지정하는 문서입니다.

db.getUser() wraps the usersInfo: <username> command.

출력에 대한 자세한 내용은 usersInfo을(를) 참조하세요.

이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

중요

This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

다른 사용자의 정보를 확인하려면 다른 사용자의 데이터베이스에 viewUser 조치가 있어야 합니다.

사용자는 자신의 정보를 확인할 수 있습니다.

다음 연산은 accounts 데이터베이스의 예시 appClient 사용자에 대한 정보를 반환합니다.

use accounts
db.getUser("appClient")

출력 예시:

{
_id: 'accounts.appClient',
userId: UUID("1c2fc1bf-c4dc-4a22-8b04-3971349ce0dc"),
user: 'appClient',
db: 'accounts',
roles: [],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}

버전 5.2의 새로운 기능:

To omit a user's custom data from the db.getUser() output, set the showCustomData option to false.

createUser 명령을 사용하여 products 데이터베이스에 accountAdmin01이라는 사용자를 생성합니다.

db.getSiblingDB("products").runCommand( {
createUser: "accountAdmin01",
pwd: passwordPrompt(),
customData: { employeeId: 12345 },
roles: [ { role: 'readWrite', db: 'products' } ]
} )

사용자에 { employeeId: 12345 }의 customData 필드가 포함됩니다.

To retrieve the user but omit the custom data from the output, run db.getUser() with showCustomData set to false:

db.getSiblingDB("products").getUser(
"accountAdmin01",
{ showCustomData: false }
)

출력 예시:

{
_id: 'products.accountAdmin01',
userId: UUID("0955afc1-303c-4683-a029-8e17dd5501f4"),
user: 'accountAdmin01',
db: 'products',
roles: [ { role: 'readWrite', db: 'products' } ],
mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ]
}
이 페이지 평가하기