📄 warifauthmodule.cpp
字号:
#include "StdAfx.h"#include "WarIfAuthModule.h" // class implemented#include "WarLog.h"#include "WarUserAuthWin32Nt.h"/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarIfAuthModule::WarIfAuthModule() :mType(AMT_INVALID){}// WarIfAuthModuleWarIfAuthModule::~WarIfAuthModule(){}// ~WarIfAuthModule//============================= OPERATORS ====================================//============================= OPERATIONS ===================================void WarIfAuthModule::SetEnable(const bool doEnable){ mRegKey.SetValue(WAR_WINNT_REG_ENABLE, doEnable);}void WarIfAuthModule::SetName(war_ccsysstr_t newName) throw(WarException){ if (!newName || !*newName) WarThrow(WarError(WAR_ERR_INVALID_ARGUMENT), NULL); mRegKey.Rename(newName); mName = newName;}//============================= ACCESS ===================================//============================= INQUIRY ===================================bool WarIfAuthModule::IsEnabled() const{ return mRegKey.GetIntValue(WAR_WINNT_REG_ENABLE, false);}war_ccsysstr_t WarIfAuthModule::GetName() const{ return mName.c_str();}war_ccsysstr_t WarIfAuthModule::GetModuleTypeName() const{ return mTypeName.c_str();}void WarIfAuthModule::EnumUsers(war_if_user_set_t& user_set, bool doIgnoreDisabledUsers) throw(WarException){ WarUserAuth::user_set_t native_users; GetAuth().EnumerateUsers(native_users); for(WarUserAuth::user_set_t::iterator P = native_users.begin() ; P != native_users.end() ; ++P) { WarUserAuthData& ruser_auth = *(*P); if (doIgnoreDisabledUsers && ruser_auth.IsEnabled()) continue; user_set.insert(new WarIfUser(war_if_aut_module_ptr_t(this), ruser_auth)); }}/////////////////////////////// PROTECTED ///////////////////////////////////void WarIfAuthModule::Open(war_if_site_ptr_t& sitePtr, const WarWin32Registry& regKey) throw(WarException){ mSitePtr = sitePtr; // Duplicate the regkey mRegKey.Create(regKey.GetRef()); mName = mRegKey.GetRef().GetPath().GetFilename().GetPath(); // Initialize war_regstr_t class_id; try { class_id = mRegKey.GetStrValue(WAR_WINNT_REG_CLASSID, NULL, true); } catch(WarException& ex) { WarLog err_log(WARLOG_ERROR, "WarIfAuthModule::Open"); err_log << "Caught exeption when retrieving class id: " << ex << war_endl; WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); } // See if we recognize the Class ID if (class_id == war_regstr_t(_T(WAR_CLSID_AUTH_NT))) { mTypeName = _T("Windows NT User Authentication"); mType = AMT_WINNT; WarPtrWrapper<WarUserAuthWin32Nt> new_module; new_module = new WarUserAuthWin32Nt; new_module->Create(mRegKey); mAuthPtr = (war_user_auth_ptr_t&)new_module; } else { WarLog err_log(WARLOG_ERROR, "WarIfAuthModule::Open"); err_log << "I don't know the auth module for \"" << GetName() << "\" (Class ID: " << class_id << ')' << war_endl; WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); }}/////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -