#include "StdAfx.h"
|
#include "MBUserLogin.h"
|
#include "MBParseServerXml.h"
|
#include "MBBaseDef.h"
|
|
#define WEB_PARAM_HOSTNAME _T("[hostname]")//Ö÷·þÎñµØÖ·
|
#define WEB_PARAM_PORT _T("[port]")//Ö÷·þÎñ¶Ë¿Ú
|
|
#define WEB_PARAM_ORGSERVER _T("[orgserver]")//org·þÎñip
|
#define WEB_PARAM_ORGSPORT _T("[orgsport]")//org·þÎñi¶Ë¿Ú
|
|
#define WEB_PARAM_LOGINNAME _T("[loginname]")//µÇ¼Óû§µÄµÇ¼Ãû
|
#define WEB_PARAM_SL _T("[sl]") //µÇ¼Óû§µÄµÇ¼Ãû P512D790¼ÓÃܺó
|
#define WEB_PARAM_USERNAME _T("[username]")//µÇ¼Óû§µÄÓû§Ãû
|
#define WEB_PARAM_SU _T("[su]")//µÇ¼Óû§µÄÓû§Ãû P512D790¼ÓÃܺó
|
|
#define WEB_PARAM_INPUTNAME _T("[inputname]")//µÇ¼ʱÊäÈëµÄÃû×Ö
|
|
#define WEB_PARAM_SP _T("[sp]")//µÇ¼Óû§µÄÃÜÂë P512D790¼ÓÃܺó
|
#define WEB_PARAM_PASSWORD _T("[password]")//µÇ¼Óû§µÄÃÜÂë
|
#define WEB_PARAM_MP _T("[mp]") //µÇ¼Óû§µÄÃÜÂë md5¼ÓÃܺó
|
|
|
#define WEB_PARAM_SESSIONID _T("[sessionid]") //Orgȇȡid
|
|
#define WEB_PARAM_TOKEN _T("[token]")//OrgȇȡToken
|
#define WEB_PARAM_CONNIP _T("[connip]")//µÇ¼Óû§µÄÍⲿip
|
#define WEB_PARAM_PCNAME _T("[pcname]")//µÇ¼Óû§µÄ¼ÆËã»úÃû³Æ
|
|
CMBUserLogin::CMBUserLogin(void)
|
{
|
m_pSvrInfo = new CMBFileSvrInfo();
|
m_pAuthInfo = new CMBAuthInfo();
|
m_bIsSysAdmin = false;
|
m_nMBCShowMode = 0;
|
m_pUserAce = new CMBUserAce();
|
m_pMBUserPro = new CMBUserPro;
|
m_asUserIP.RemoveAll();
|
|
m_strOrgServer = _T("");
|
m_nOrgServerPort = DEFAULTPORT_ORG;
|
|
m_strFileSFlag = _T("");
|
|
m_strAceServer = _T("");
|
m_nAceServerPort = DEFAULTPORT_ACE;
|
m_nMoboxSPort = DEFAULTPORT_MOBOX;
|
m_strMoboxServer= _T("");
|
|
m_nNetDiakSPort = DEFAULTPORT_NETDISK;
|
m_strNetDiakServer= _T("");
|
|
m_nCalendarWebSPort = DEFAULTPORT_CANLENDARWEB;
|
m_strCalendarWebServer= _T("");
|
m_strMainCrowdServer = _T("");
|
m_nMainCrowdPort = DEFAULTPORT_MCROWD ;
|
m_strUpsServer = _T("");
|
m_nUpsServerPort = DEFAULTPORT_UPS ;
|
m_strExtServer = _T("");
|
m_nExtServerPort = DEFAULTPORT_EXT ;
|
|
m_strExtWebServer = _T("");
|
m_nExtWebServerPort = DEFAULTPORT_EXTWEB ;
|
m_bIsOffline = false; // ÊÇÀëÏß״̬
|
|
m_strDataServer = _T("");
|
m_nDataPort = DEFAULTPORT_DATA;
|
}
|
|
|
CMBUserLogin::~CMBUserLogin(void)
|
{
|
if( m_pSvrInfo )
|
{
|
delete m_pSvrInfo;
|
m_pSvrInfo = NULL;
|
}
|
if( m_pAuthInfo )
|
{
|
delete m_pAuthInfo;
|
m_pAuthInfo = NULL;
|
}
|
if( m_pUserAce )
|
{
|
delete m_pUserAce;
|
m_pUserAce = NULL;
|
}
|
|
|
}
|
|
CMBFileSvrInfo *CMBUserLogin::GetFileSvrInfo()
|
{
|
return m_pSvrInfo;
|
}
|
|
bool CMBUserLogin::ParseUserLoginXml( CString &strXml )
|
{
|
return CMBParseServerXml::ParseLoginInfo(strXml,this);
|
}
|
|
//bool CMBUserLogin::ParseUserInfoXml( CString &strXml,CString &strErrInfo )
|
//{
|
// pugi::xml_document xmlDoc;
|
// if (!xmlDoc.load(strXml))
|
// {
|
// return false;
|
// }
|
// CString strSecret;
|
// pugi::xml_node form = xmlDoc.child(_T("User"));
|
// m_strLoginName = form.attribute(_T("Login")).value();
|
// m_strUserName = form.attribute(_T("Name")).value();
|
// m_pMBUser->m_strAlias = form.attribute(_T("Alias")).value();
|
//
|
// m_pMBUser->m_strNamePY = form.attribute(_T("NamePY")).value();
|
// m_pMBUser->m_strDispName = form.attribute(_T("DispName")).value();
|
// m_pMBUser->m_strLevel = form.attribute(_T("Level")).value();
|
// m_pMBUser->m_strState = form.attribute(_T("State")).value();
|
// m_pMBUser->m_strPhoto = form.attribute(_T("Photo")).value();
|
// strSecret= form.attribute(_T("Secret")).value();
|
// m_pMBUser->m_nSecret = _ttoi(strSecret);
|
// m_pMBUser->m_strSex = form.attribute(_T("Sex")).value();
|
// m_pMBUser->m_strDTJoin = form.attribute(_T("DTJoin")).value();
|
// m_pMBUser->m_strMobile = form.attribute(_T("Mobile")).value();
|
// m_pMBUser->m_strEmail = form.attribute(_T("Email")).value();
|
// m_pMBUser->m_strDepart = form.attribute(_T("Depart")).value();
|
// m_pMBUser->m_strUnit = form.attribute(_T("Unit")).value();
|
// m_pMBUser->m_strSign = form.child_value(_T("Sign")) ;
|
//
|
// return true;
|
//}
|
BOOL CMBUserLogin::ParseOrgBaseInfoXml( CString &strXmlBuff,CString &strErrInfo )
|
{
|
if(strXmlBuff.IsEmpty())
|
return FALSE;
|
COIXMLParser xmlParser;
|
IXMLDOMElementPtr ptrBody;
|
IXMLDOMNodePtr ptrNode,ptrNext;
|
CString strNodeName,strNodeValue,strAttrValue;
|
if( !xmlParser.ParseXMLStr(strXmlBuff, ptrBody) )
|
{
|
return FALSE;
|
}
|
COIXMLParser::GetNodeContent(ptrBody, strNodeName, strNodeValue);
|
if(0 != strNodeName.CompareNoCase(_T("Body")))
|
{
|
return FALSE;
|
}
|
ptrBody->get_firstChild( &ptrNode);
|
while(ptrNode)
|
{
|
COIXMLParser::GetNodeContent(ptrNode, strNodeName, strNodeValue);
|
if ( strNodeName.CompareNoCase( _T("Name") ) == 0 )
|
{
|
m_strCompany= strNodeValue;
|
}
|
else if ( strNodeName.CompareNoCase( _T("ShortName") ) == 0 )
|
{
|
m_strCompanyShort= strNodeValue;
|
}
|
ptrNode->get_nextSibling( &ptrNext);
|
ptrNode = ptrNext;
|
}
|
return TRUE;
|
}
|
|
//====================================
|
// »ñÈ¡±¾»úÃû³Æ
|
//====================================
|
bool CMBUserLogin::GetHostName( )
|
{
|
char strHost[260] = { 0 };
|
LPWSTR pszW = NULL;
|
if( SOCKET_ERROR == gethostname(strHost, sizeof(strHost)) )
|
return false;
|
if ( CBaseCommFun::AnsiToUnicode((LPCSTR)strHost, &pszW))
|
{
|
m_strPCName.Format(_T("%s"), pszW);
|
CoTaskMemFree( pszW );
|
}
|
return true;
|
}
|
//====================================
|
// »ñÈ¡±¾»úµÄIPµØÖ·
|
//====================================
|
bool CMBUserLogin::GetHostIP( CStringArray &asIP )
|
{
|
char strHost[260] = { 0 };
|
LPWSTR pszW = NULL;
|
asIP.RemoveAll();
|
if( SOCKET_ERROR == gethostname(strHost, sizeof(strHost)) )
|
return false;
|
if ( CBaseCommFun::AnsiToUnicode((LPCSTR)strHost, &pszW))
|
{
|
m_strPCName.Format(_T("%s"), pszW);
|
CoTaskMemFree( pszW );
|
}
|
struct hostent *hp = NULL;
|
hp = gethostbyname(strHost);
|
if (hp != NULL && hp->h_addr_list[0] != NULL)
|
{
|
if ( hp ->h_length < 4)
|
return TRUE;
|
}
|
CString strLog;
|
int nAdapter = 0;
|
CString strIPTemp;
|
in_addr address;
|
|
while( hp->h_addr_list[nAdapter] )
|
{
|
CopyMemory(&address.S_un.S_addr, hp->h_addr_list[nAdapter], hp->h_length);
|
strIPTemp = inet_ntoa (address);
|
asIP.Add( strIPTemp );
|
nAdapter ++;
|
}
|
return true;
|
}
|
void CMBUserLogin::ReplaceSysValue(CString &strData )
|
{
|
CString strPassword;
|
CString strLoginName, strUserName;
|
|
CString strParam = strData;
|
//strParam.MakeLower();
|
|
strParam.Replace(WEB_PARAM_LOGINNAME, m_strLoginName );
|
strParam.Replace(WEB_PARAM_INPUTNAME, m_strInputName );
|
strParam.Replace(WEB_PARAM_USERNAME,m_strUserName );
|
strParam.Replace(WEB_PARAM_PASSWORD,m_strPwd );
|
strParam.Replace(WEB_PARAM_TOKEN,m_strToken );
|
|
strPassword = m_strPwd;
|
CEncrypt::Encrypt( strPassword, _T("P512D790") );
|
strParam.Replace( WEB_PARAM_SP , strPassword );
|
|
strLoginName = m_strLoginName;
|
CEncrypt::Encrypt( strLoginName, _T("P512D790") );
|
strParam.Replace( WEB_PARAM_SL, strLoginName );
|
|
strUserName = m_strUserName ;
|
CEncrypt::Encrypt( strUserName, _T("P512D790") );
|
strParam.Replace( WEB_PARAM_SU, strUserName );
|
|
strPassword =m_strPwd;
|
MD5Encrypt( strPassword );
|
strParam.Replace( WEB_PARAM_MP, strPassword );
|
|
strParam.Replace(WEB_PARAM_HOSTNAME, m_strServerName);
|
strParam.Replace(WEB_PARAM_SESSIONID, m_strSessionID);
|
strParam.Replace(WEB_PARAM_PORT,m_strPort);
|
|
strParam.Replace(WEB_PARAM_ORGSERVER, m_strServerName);
|
strParam.Replace(WEB_PARAM_ORGSPORT, m_strPort);
|
|
strParam.Replace(WEB_PARAM_PCNAME, m_strPCName);
|
strParam.Replace(WEB_PARAM_CONNIP, m_strUserConnIP);
|
strData = strParam;
|
//strData = CSTKCommFun::URLEncode(strParam);
|
//CSTKCommFun::WriteLog(strData);
|
}
|
|
//===================================
|
// MD5¼ÓÃÜ
|
//===================================
|
void CMBUserLogin::MD5Encrypt( CString &strData )
|
{
|
CMD5Encrypt md5;
|
TCHAR szEncrypt[33] = { 0 };
|
CString strStuff;
|
int nLength(0);
|
|
strStuff = strData;
|
nLength = strStuff.GetLength();
|
md5.digest_md5( (TCHAR*)strStuff.GetBuffer( nLength ), nLength, szEncrypt );
|
strStuff.ReleaseBuffer();
|
|
strData = szEncrypt;
|
}
|
CMBAuthInfo *CMBUserLogin::GetAuthInfo()
|
{
|
return m_pAuthInfo;
|
}
|
|
CMBUserAce *CMBUserLogin::GetUserAce()
|
{
|
return m_pUserAce;
|
}
|
CMBUserPro *CMBUserLogin::GetUserPro()
|
{
|
return m_pMBUserPro;
|
}
|