MongoDB
PHP Manual

MongoDB::authenticate

(PECL mongo >=1.0.1)

MongoDB::authenticateLog in to this database

説明

public array MongoDB::authenticate ( string $username , string $password )

This method causes its connection to be authenticated. If authentication is enabled for the database server (it's not, by default), you need to log in before the database will allow you to do anything.

This method is identical to running:

<?php

$salted 
"${username}:mongo:${password}";
$hash md5($salted);

$nonce $db->command(array("getnonce" => 1));

$saltedHash md5($nonce["nonce"]."${username}${hash}");

$result $db->command(array("authenticate" => 1
    
"user" => $username,
    
"nonce" => $nonce["nonce"],
    
"key" => $saltedHash);

?>

パラメータ

username

The username.

password

The password (in plaintext).

返り値

Returns database response.

参考

MongoDB core docs on » authenticate.


MongoDB
PHP Manual