⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proppageauthmodulewindows.cpp

📁 ftpserver very good sample
💻 CPP
字号:
// PropPageAuthModuleWindows.cpp : implementation file//#include "stdafx.h"#include <Lm.h>#include "warmmcsnapin.h"#include "PropPageAuthModuleWindows.h"#include "WarUserAuthWin32Nt.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CPropPageAuthModuleWindows property pageIMPLEMENT_DYNCREATE(CPropPageAuthModuleWindows, CPropertyPage)CPropPageAuthModuleWindows::CPropPageAuthModuleWindows(war_if_aut_module_ptr_t& authPtr) : CPropertyPage(CPropPageAuthModuleWindows::IDD),mAuthPtr(authPtr){    WarUserAuthWin32Nt& my_auth = (WarUserAuthWin32Nt &)(mAuthPtr->GetAuth());	//{{AFX_DATA_INIT(CPropPageAuthModuleWindows)	m_bUseLocalMachine = my_auth.IsUsingLocalMachine();	m_Server = my_auth.GetAuthServer().GetValue().c_str();	m_Group = my_auth.GetAuthGroup().GetValue().c_str();	m_AnonUser = my_auth.GetAnonUser().GetValue().c_str();	m_AnonPasswd = my_auth.GetAnonPasswd().GetValue().c_str();	//}}AFX_DATA_INIT}CPropPageAuthModuleWindows::~CPropPageAuthModuleWindows(){    if (!m_AnonPasswd.IsEmpty())        memset(m_AnonPasswd.GetBuffer(0), 0, m_AnonPasswd.GetLength());}void CPropPageAuthModuleWindows::DoDataExchange(CDataExchange* pDX){	CPropertyPage::DoDataExchange(pDX);	//{{AFX_DATA_MAP(CPropPageAuthModuleWindows)	DDX_Control(pDX, IDC_GROUP, m_ctlGroup);	DDX_Check(pDX, IDC_LOCAL_MACHINE, m_bUseLocalMachine);	DDX_Text(pDX, IDC_SERVER, m_Server);	DDX_CBString(pDX, IDC_GROUP, m_Group);	DDX_Text(pDX, IDC_ANON_USER, m_AnonUser);	DDX_Text(pDX, IDC_ANON_PASSWD, m_AnonPasswd);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CPropPageAuthModuleWindows, CPropertyPage)	//{{AFX_MSG_MAP(CPropPageAuthModuleWindows)	ON_BN_CLICKED(IDC_LOCAL_MACHINE, OnLocalMachine)	ON_EN_CHANGE(IDC_SERVER, OnChange)	ON_CBN_EDITCHANGE(IDC_GROUP, OnChange)	ON_CBN_SELCHANGE(IDC_GROUP, OnChange)	ON_EN_CHANGE(IDC_ANON_USER, OnChange)	ON_EN_CHANGE(IDC_ANON_PASSWD, OnChange)	ON_CBN_DROPDOWN(IDC_GROUP, OnDropdownGroup)	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CPropPageAuthModuleWindows message handlersBOOL CPropPageAuthModuleWindows::OnInitDialog() {	CPropertyPage::OnInitDialog();		DoSetStates();		return TRUE;  // return TRUE unless you set the focus to a control	              // EXCEPTION: OCX Property Pages should return FALSE}BOOL CPropPageAuthModuleWindows::OnApply() {    UpdateData();    WarUserAuthWin32Nt& my_auth = (WarUserAuthWin32Nt &)(mAuthPtr->GetAuth());    if (!m_bUseLocalMachine && m_Server.IsEmpty())    {        AfxMessageBox(IDS_NOSERVERNAME);        return FALSE;    }    my_auth.SetUsingLocalMachine(m_bUseLocalMachine);    WarUserAuthWin32Nt::netstr_t net_str(WarUserAuthWin32Nt::netstr_t::SM_ERASE);    net_str = m_Server;	my_auth.SetAuthServer(net_str);    net_str = m_Group;	my_auth.SetAuthGroup(net_str);    net_str = m_AnonUser;	my_auth.SetAnonUser(net_str);    net_str = m_AnonPasswd;	my_auth.SetAnonPasswd(net_str);		return CPropertyPage::OnApply();}void CPropPageAuthModuleWindows::OnLocalMachine() {    UpdateData();    OnChange();    DoSetStates();}void CPropPageAuthModuleWindows::OnChange() {    SetModified();}void CPropPageAuthModuleWindows::DoSetStates(){    GetDlgItem(IDC_SERVER)->EnableWindow(m_bUseLocalMachine == false);}void CPropPageAuthModuleWindows::OnDropdownGroup() {    UpdateData();    m_ctlGroup.ResetContent();        // Enumerate the local groups on the selected server    WarCollector<wchar_t> net_sever;    if (!m_bUseLocalMachine)        net_sever << m_Server;        do    {        LPBYTE return_buf = NULL;        DWORD entries_read = 0;        DWORD total_entries = 0;        DWORD_PTR resume_handle = NULL;                NET_API_STATUS status = NetLocalGroupEnum(            m_bUseLocalMachine ? NULL : net_sever.GetValue().c_str(),            0,            &return_buf,            MAX_PREFERRED_LENGTH,            &entries_read,            &total_entries,            &resume_handle);                PLOCALGROUP_INFO_0 p = (PLOCALGROUP_INFO_0)return_buf;        for(DWORD index = 0; index < entries_read; index++)        {            WarCollector<TCHAR> name = p->lgrpi0_name;            m_ctlGroup.AddString(name.GetValue().c_str());            p++;        }                if (return_buf)            NetApiBufferFree(return_buf);                switch(status)        {        case NERR_InvalidComputer:            AfxMessageBox(_T("Invalid computer"));            return;        case ERROR_MORE_DATA:            break;        case ERROR_ACCESS_DENIED:            AfxMessageBox(_T("Access denied to NT group information"));            return;        case NERR_Success:            return;        default:            AfxMessageBox(_T("Failed to fetch group information"));            return;        }    } while(false);        return;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -