MongoDB::authenticate

(PECL mongo >=1.0.1)

MongoDB::authenticate锟斤拷录锟斤拷锟斤拷锟捷匡拷

说锟斤拷

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

锟剿凤拷锟斤拷锟杰癸拷锟斤拷证锟斤拷锟斤拷锟斤拷锟接★拷 锟斤拷锟斤拷锟斤拷菘锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷证锟斤拷默锟斤拷没锟叫匡拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿何诧拷锟斤拷之前锟斤拷锟斤拷要锟斤拷录锟斤拷

通锟斤拷锟斤拷锟斤拷拢锟斤拷锟接︼拷锟绞癸拷锟� MongoClient::__construct() 锟斤拷锟矫的诧拷锟斤拷锟斤拷锟斤拷锟角此凤拷锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷证锟剿o拷然锟斤拷锟节会话锟节硷拷锟斤拷锟接碉拷锟斤拷然锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷岜伙拷锟斤拷锟斤拷锟街わ拷锟� 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街讹拷锟斤拷证锟斤拷然锟斤拷锟斤拷锟接碉拷锟剿o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷侄锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷

锟矫凤拷锟斤拷锟斤拷同锟斤拷锟斤拷锟叫o拷

<?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
));

?>

锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷证锟斤拷锟斤拷锟斤拷锟杰癸拷通锟斤拷 "logout" 锟斤拷锟捷匡拷锟斤拷锟斤拷锟斤拷锟角筹拷锟斤拷

<?php

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

?>

锟斤拷锟斤拷

username

锟矫伙拷锟斤拷锟斤拷

password

锟斤拷锟诫(锟斤拷锟侥革拷式锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷锟捷匡拷锟斤拷锟接︼拷锟斤拷锟斤拷锟斤拷录锟缴癸拷锟斤拷锟斤拷锟结返锟斤拷

<?php
array("ok" => 1);
?>
锟斤拷锟斤拷锟斤拷锟斤拷锟绞裁达拷锟斤拷锟斤拷锟斤拷岱碉拷锟�
<?php
array("ok" => 0"errmsg" => "auth fails");
?>
锟斤拷"auth fails" 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较拷锟饺★拷锟斤拷锟斤拷锟斤拷菘锟芥本锟酵凤拷锟斤拷锟斤拷什么锟斤拷锟襟)★拷

锟轿硷拷

MongoDB 锟斤拷锟斤拷 » authenticate 锟侥猴拷锟斤拷锟侥碉拷锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
1.2.11 使锟斤拷时锟斤拷锟斤拷 E_DEPRECATED锟斤拷 锟诫将锟斤拷证细锟节达拷锟诫到锟斤拷锟斤拷锟斤拷锟斤拷