// user.cpp : Implementation of CSmtpadmApp and UserL registration. #include "stdafx.h" #include "smtpadm.h" #include "user.h" #include "oleutil.h" #include #include "smtpcmn.h" // Must define THIS_FILE_* macros to use SmtpCreateException() #define THIS_FILE_HELP_CONTEXT 0 #define THIS_FILE_PROG_ID _T("Smtpadm.User.1") #define THIS_FILE_IID IID_ISmtpAdminUser #define DEFAULT_NEWSGROUP_NAME _T("") #define DEFAULT_NEWSGROUP_DESCRIPTION _T("") #define DEFAULT_NEWSGROUP_MODERATOR _T("") #define DEFAULT_NEWSGROUP_READONLY FALSE ///////////////////////////////////////////////////////////////////////////// // // // Use a macro to define all the default methods // DECLARE_METHOD_IMPLEMENTATION_FOR_STANDARD_EXTENSION_INTERFACES(SmtpAdminUser, CSmtpAdminUser, IID_ISmtpAdminUser) STDMETHODIMP CSmtpAdminUser::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_ISmtpAdminUser, }; for (int i=0;iwszVRoot; m_strForwardEmail = pUserProps->wszForward; m_fAutoForward = (!m_strForwardEmail || !m_strForwardEmail.Length()) ? FALSE : TRUE; m_lInboxSizeInMemory = pUserProps->dwMailboxMax; m_lInboxSizeInMsgNumber = pUserProps->dwMailboxMessageMax; m_fLocal = !!pUserProps->dwLocal; // free pUserProps if ( pUserProps ) { ::NetApiBufferFree ( pUserProps ); } Exit: TraceFunctLeave (); return hr; } STDMETHODIMP CSmtpAdminUser::Set ( ) { TraceFunctEnter ( "CSmtpAdminUser::Set" ); HRESULT hr = NOERROR; DWORD dwErr = NOERROR; SMTP_USER_PROPS UserProps; if( !m_strEmailId || !m_strDomain ) { hr = SmtpCreateException ( IDS_SMTPEXCEPTION_INVALID_ADDRESS ); goto Exit; } WCHAR szUserName[512]; wsprintfW( szUserName, L"%s@%s", (LPWSTR) m_strEmailId, (LPWSTR) m_strDomain ); UserProps.fc = FC_SMTP_USER_PROPS_ALL; if( !m_strForwardEmail || !m_strForwardEmail.Length() ) { UserProps.wszForward = NULL; UserProps.fc -= FC_SMTP_USER_PROPS_FORWARD; } else { UserProps.wszForward = (LPWSTR)m_strForwardEmail; } UserProps.wszVRoot = (LPWSTR)m_strMailRoot; UserProps.dwMailboxMax = m_lInboxSizeInMemory; UserProps.dwMailboxMessageMax = m_lInboxSizeInMsgNumber; UserProps.dwLocal = m_fLocal; dwErr = SmtpSetUserProps( m_iadsImpl.QueryComputer(), szUserName, &UserProps, m_iadsImpl.QueryInstance() ); if ( dwErr != NOERROR ) { ErrorTrace ( (LPARAM) this, "Failed to set user prop: %x", dwErr ); hr = SmtpCreateExceptionFromWin32Error ( dwErr ); goto Exit; } Exit: TraceFunctLeave (); return hr; }