本文整理汇总了C++中AuthenticationInfo::isAuthorizedReads方法的典型用法代码示例。如果您正苦于以下问题:C++ AuthenticationInfo::isAuthorizedReads方法的具体用法?C++ AuthenticationInfo::isAuthorizedReads怎么用?C++ AuthenticationInfo::isAuthorizedReads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthenticationInfo
的用法示例。
在下文中一共展示了AuthenticationInfo::isAuthorizedReads方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool run(const string& dbname , BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
AuthenticationInfo *ai = cc().getAuthenticationInfo();
uassert( 12598 , "$eval reads unauthorized", ai->isAuthorizedReads(dbname.c_str()) );
if ( cmdObj["nolock"].trueValue() ) {
return dbEval(dbname, cmdObj, result, errmsg);
}
// write security will be enforced in DBDirectClient
mongolock lk( ai->isAuthorized( dbname.c_str() ) );
Client::Context ctx( dbname );
return dbEval(dbname, cmdObj, result, errmsg);
}
示例2: run
bool run(const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
AuthenticationInfo *ai = cc().getAuthenticationInfo();
uassert( 12598 , "$eval reads unauthorized", ai->isAuthorizedReads(dbname.c_str()) );
if ( cmdObj["nolock"].trueValue() ) {
return dbEval(dbname, cmdObj, result, errmsg);
}
// write security will be enforced in DBDirectClient
// TODO: should this be a db lock?
scoped_ptr<Lock::ScopedLock> lk( ai->isAuthorized( dbname.c_str() ) ?
static_cast<Lock::ScopedLock*>( new Lock::GlobalWrite() ) :
static_cast<Lock::ScopedLock*>( new Lock::GlobalRead() ) );
Client::Context ctx( dbname );
return dbEval(dbname, cmdObj, result, errmsg);
}