Пример #1
0
static HRESULT GetGCSearch(IDirectorySearch **ppDS)
{
    HRESULT hr;
    IEnumVARIANT *pEnum = NULL;
    IADsContainer *pCont = NULL;
    IDispatch *pDisp = NULL;
    VARIANT var;
    ULONG lFetch;

    *ppDS = NULL;

    /* Bind to the GC: namespace container object. The true GC DN 
      is a single immediate child of the GC: namespace, which must 
      be obtained using enumeration. */
    hr = ADsOpenObject(L"GC:", NULL, NULL, ADS_SECURE_AUTHENTICATION, /* Use Secure Authentication. */
	IID_IADsContainer,
	(void**)&pCont);
    if (FAILED(hr)) 
    {
	smpd_err_printf("ADsOpenObject failed: 0x%x\n", hr);
	goto cleanup;
    } 

    /* Get an enumeration interface for the GC container.  */
    hr = ADsBuildEnumerator(pCont, &pEnum);
    if (FAILED(hr)) 
    {
	smpd_err_printf("ADsBuildEnumerator failed: 0x%x\n", hr);
	goto cleanup;
    } 

    /* Now enumerate. There is only one child of the GC: object. */
    hr = ADsEnumerateNext(pEnum, 1, &var, &lFetch);
    if (FAILED(hr)) 
    {
	smpd_err_printf("ADsEnumerateNext failed: 0x%x\n", hr);
	goto cleanup;
    } 

    if ((hr == S_OK) && (lFetch == 1))
    {
	pDisp = V_DISPATCH(&var);
	hr = pDisp->QueryInterface(IID_IDirectorySearch, (void**)ppDS); 
    }

cleanup:
    if (pEnum)
    {
	ADsFreeEnumerator(pEnum);
	pEnum = NULL;
    }

    if (pCont)
    {
	pCont->Release();
	pCont = NULL;
    }

    if (pDisp)
    {
	pDisp->Release();
	pDisp = NULL;
    }

    return hr;
}
Пример #2
0
eResult CSecRunAsUser::PrepareUser(){
	CoInitialize(NULL);
	bool bResult = false;
	if (!LoadAPI())
		return RES_FAILED;

	try{
		IADsContainerPtr pUsers;
		try{
			IADsWinNTSystemInfoPtr pNTsys;
			if (CoCreateInstance(CLSID_WinNTSystemInfo,NULL,CLSCTX_INPROC_SERVER,IID_IADsWinNTSystemInfo,(void**)&pNTsys) != S_OK)
			    throw CString(_T("Failed to create IADsWinNTSystemInfo"));
			// check if we are already running on our eMule Account
			// todo: check if the current account is an administrator
			
			CComBSTR bstrUserName;
			pNTsys->get_UserName(&bstrUserName);
			m_strCurrentUser = bstrUserName;

			if (m_strCurrentUser == EMULEACCOUNTW){ 
				m_bRunningAsEmule = true;
			    throw CString(_T("Already running as eMule_Secure Account (everything is fine)"));
			}
			CComBSTR bstrCompName;
			pNTsys->get_ComputerName(&bstrCompName);
			CStringW cscompName = bstrCompName;

			CComBSTR bstrDomainName;
			pNTsys->get_DomainName(&bstrDomainName);
			m_strDomain = bstrDomainName;
		
			ADSPath.Format(L"WinNT://%s,computer",cscompName);
			if ( !SUCCEEDED(ADsGetObject(ADSPath.AllocSysString(),IID_IADsContainer,(void **)&pUsers)) )
			    throw CString(_T("Failed ADsGetObject()"));

			IEnumVARIANTPtr pEnum; 
			ADsBuildEnumerator (pUsers,&pEnum);

			IADsUserPtr pChild;
			_variant_t vChild;			  
			while( ADsEnumerateNext (pEnum,1,&vChild,NULL) == S_OK )
			{	
				if (vChild.pdispVal->QueryInterface(IID_IADsUser,(void **)&pChild) != S_OK)
					continue;
				//If the object in the container is user then get properties
				CComBSTR bstrName; 
				pChild->get_Name(&bstrName);
				CStringW csName= bstrName;
				
				// find the emule user account if possible
				if ( csName == EMULEACCOUNTW ){
					// account found, set new random password and save it
					m_strPassword = CreateRandomPW();
					if ( !SUCCEEDED(pChild->SetPassword(m_strPassword.AllocSysString())) )
					    throw CString(_T("Failed to set password"));

					bResult = true;
					break;
				}
			}

		}
		catch(CString error){
			// clean up and abort
			theApp.QueueDebugLogLine(false, _T("Run as unpriveleged user: Exception while preparing user account: %s!"), error);
			CoUninitialize();
			if (m_bRunningAsEmule)
				return RES_OK;
			else
				return RES_FAILED;
		}
		if (bResult || CreateEmuleUser(pUsers) ){
			bResult = SetDirectoryPermissions();
		}
	}
	catch(...){
		// clean up and abort
		theApp.QueueDebugLogLine(false, _T("Run as unpriveleged user: Unexpected fatal error while preparing user account!"));
		CoUninitialize();
		return RES_FAILED;
	}



	CoUninitialize();
	FreeAPI();
	if (bResult)
		return RES_OK_NEED_RESTART;
	else
		return RES_FAILED;
}
Пример #3
0
int main(int argc, char* argv[])
{
	HRESULT hr;
	IADsContainer *pCont=NULL;

	CoInitialize(NULL);
	///////////////////////////////////
	// Bind to the object
	/////////////////////////////////
	hr = ADsGetObject(L"WinNT://INDEPENDENCE", IID_IADsContainer, (void**) &pCont );
	if ( !SUCCEEDED(hr) )
	{
		return hr;
	}

	///////////////////////////////////
	// Build variant filter
	/////////////////////////////////
	LPWSTR pszFilter[] = { L"user", L"group" };
	DWORD dwNumber = sizeof( pszFilter ) /sizeof(LPWSTR);
	VARIANT var;

	hr = ADsBuildVarArrayStr( pszFilter, dwNumber, &var );

	if ( !SUCCEEDED(hr) )
	{
		pCont->Release();
		return hr;
	}

	///////////////////////////////////
	// Set the filter
	/////////////////////////////////

	hr = pCont->put_Filter(var);
	VariantClear(&var);

	if (!SUCCEEDED(hr) )
	{
		pCont->Release();
		return hr;
	}

	////////////////////////////////////////////
	// Enumerate the result
	///////////////////////////////////////////////
	IEnumVARIANT *pEnum = NULL;
	hr = ADsBuildEnumerator( pCont, &pEnum );
	pCont->Release(); // no longer needed, since we have the enumerator already
	
	if ( SUCCEEDED(hr) )
	{
		VARIANT var;
		ULONG lFetch;
		IADs *pChild=NULL;
		VariantInit(&var);
		
		while( SUCCEEDED(ADsEnumerateNext( pEnum, 1, &var, &lFetch )) && lFetch == 1 )
		{
			hr = V_DISPATCH(&var)->QueryInterface( IID_IADs, (void**) &pChild );
			if ( SUCCEEDED(hr) )
			{
				BSTR bstrName;
				BSTR bstrClass;
				// Get more information on the child classes
				pChild->get_Name(&bstrName);
				pChild->get_Class(&bstrClass);
				
				printf("%S\t\t(%S)\n", bstrName, bstrClass );
				
				// Clean-up
				SysFreeString(bstrName);
				SysFreeString(bstrClass);
				
				pChild->Release();
			}
			VariantClear(&var);
		}
	}
              
              
              if ( pEnum )
	{
		ADsFreeEnumerator( pEnum );
	}

	CoUninitialize();

	return 0;
}
Пример #4
0
BOOL RecursiveIsMember(IADsGroup * pADsGroup,LPWSTR pwszMemberGUID,LPWSTR pwszMemberPath, 
                                             BOOL bVerbose, LPOLESTR  pwszUser, LPOLESTR pwszPassword)
{
    HRESULT         hr                = S_OK;     // COM Result Code
    IADsMembers *   pADsMembers       = NULL;     // Ptr to Members of the IADsGroup
    BOOL            fContinue         = TRUE;     // Looping Variable
    IEnumVARIANT *  pEnumVariant      = NULL;     // Ptr to the Enum variant
    IUnknown *      pUnknown          = NULL;     // IUnknown for getting the ENUM initially
    VARIANT         VariantArray[FETCH_NUM];      // Variant array for temp holding returned data
    ULONG           ulElementsFetched = NULL;     // Number of elements retrieved
    BSTR            bsGroupPath       = NULL;
    BOOL            bRet              = FALSE;

    if(!pADsGroup || !pwszMemberGUID || !pwszMemberPath)
    {
        return FALSE;
    }
 
    // Get the path of the object passed in
    hr = pADsGroup->get_ADsPath(&bsGroupPath);
 
    if (!SUCCEEDED(hr))
        return hr;
 
    if (bVerbose)
    {
        WCHAR pwszOutput[2048];
        wsprintf(pwszOutput,L"Checking the Group:\n\n%s\n\n for the member:\n\n%s\n\n",bsGroupPath,pwszMemberPath);
        PrintBanner(pwszOutput);
    }
 
    // Get an interface pointer to the IADsCollection of members
    hr = pADsGroup->Members(&pADsMembers);
 
    if (SUCCEEDED(hr))
    {
        // Query the IADsCollection of members for a new ENUM Interface
        // Be aware that the enum comes back as an IUnknown *
        hr = pADsMembers->get__NewEnum(&pUnknown);
 
        if (SUCCEEDED(hr))
        {
            // QI the IUnknown * for an IEnumVARIANT interface
            hr = pUnknown->QueryInterface(IID_IEnumVARIANT, (void **)&pEnumVariant);
 
            if (SUCCEEDED(hr))
            {
                // While have not hit errors or end of data....
                while (fContinue) 
                {
                   ulElementsFetched = 0;
                    // Get a "batch" number of group members-number of rows specified by FETCH_NUM
                    hr = ADsEnumerateNext(pEnumVariant, FETCH_NUM, VariantArray, &ulElementsFetched);
 
                    if (ulElementsFetched )
                    {
                        // Loop through the current batch-printing the path for each member.
                        for (ULONG i = 0; i < ulElementsFetched; i++ ) 
                        {
                            IDispatch * pDispatch         = NULL; // ptr for holding dispath of element
                            BSTR        bstrCurrentPath   = NULL; // Holds path of object
                            BSTR        bstrGuidCurrent   = NULL; // Holds path of object
                            IDirectoryObject * pIDOCurrent = NULL;// Holds the current object          
 
                            // Get the dispatch ptr for the variant
                            pDispatch = VariantArray[i].pdispVal;
//                            assert(HAS_BIT_STYLE(VariantArray[i].vt,VT_DISPATCH));
 
                            // Get the IADs interface for the "member" of this group
                            hr = pDispatch->QueryInterface(IID_IDirectoryObject,
                                                           (VOID **) &pIDOCurrent ) ;
 
                            if (SUCCEEDED(hr))
                            {
                                // Get the GUID for the current object
                                hr = GetObjectGuid(pIDOCurrent,bstrGuidCurrent);
 
                                if (FAILED(hr))
                                    return hr;
 
                                IADs * pIADsCurrent = NULL;
 
                                // Retrieve the IADs Interface for the current object
                                hr = pIDOCurrent->QueryInterface(IID_IADs,(void**)&pIADsCurrent);
                                if (FAILED(hr))
                                    return hr;
 
                                // Get the ADsPath property for this member
                                hr = pIADsCurrent->get_ADsPath(&bstrCurrentPath);
 
                                if (SUCCEEDED(hr))
                                {
                                    if (bVerbose)
                                        wprintf(L"Comparing:\n\n%s\nWITH:\n%s\n\n",bstrGuidCurrent,pwszMemberGUID);
                                    
                                    // Verify that the member of this group is Equal to passed.
                                    if (_wcsicmp(bstrGuidCurrent,pwszMemberGUID)==0)
                                    {
                                        if (bVerbose)
                                            wprintf(L"!!!!!Object:\n\n%s\n\nIs a member of\n\n%s\n\n",pwszMemberPath,bstrGuidCurrent);   
 
                                        bRet = TRUE;
                                        break;
                                    }
                                    else // Otherwise, bind to this and see if it is a group.
                                    {    // If is it a group then the QI to IADsGroup succeeds
                                        
                                        IADsGroup * pIADsGroupAsMember = NULL;
                                        
                                        if (pwszUser)
                                            hr = ADsOpenObject( bstrCurrentPath,
                                                                pwszUser, 
                                                                pwszPassword, 
                                                                ADS_SECURE_AUTHENTICATION,
                                                                IID_IADsGroup, 
                                                                (void**) &pIADsGroupAsMember);
                                        else
                                            hr = ADsGetObject( bstrCurrentPath, IID_IADsGroup,(void **)&pIADsGroupAsMember);
 
                                        // If bind was completed, then this is a group.
                                        if (SUCCEEDED(hr))
                                        {
                                            // Recursively call this group to verify this group.
                                            BOOL bRetRecurse;
                                            bRetRecurse = RecursiveIsMember(pIADsGroupAsMember,pwszMemberGUID,pwszMemberPath,bVerbose,pwszUser ,pwszPassword );
                                            
                                            if (bRetRecurse)
                                            {
                                                bRet = TRUE;
                                                break;
                                            }
                                            pIADsGroupAsMember->Release();
                                            pIADsGroupAsMember = NULL;
                                        }
                                    }
                                    SysFreeString(bstrCurrentPath);
                                    bstrCurrentPath = NULL;
 
                                    SysFreeString(bstrGuidCurrent);
                                    bstrGuidCurrent = NULL;
                                }
                                // Release
                                pIDOCurrent->Release();
                                pIDOCurrent = NULL;
                                if (pIADsCurrent)
                                {
                                    pIADsCurrent->Release();
                                    pIADsCurrent = NULL;
                                }
                            }
                         }
                        // Clear the variant array.
                        memset(VariantArray, 0, sizeof(VARIANT)*FETCH_NUM);
                    }
                    else
                        fContinue = FALSE;
                }
                pEnumVariant->Release();
                pEnumVariant = NULL;
            }
            pUnknown->Release();
            pUnknown = NULL;
        }
        pADsMembers ->Release();
        pADsMembers  = NULL;
    }
 
    // Free the group path if retrieved.
    if (bsGroupPath)
    {
        SysFreeString(bsGroupPath);
        bsGroupPath = NULL;
    }
    return bRet;
}
Пример #5
0
void SMTPServersNT( CCFXRequest* pRequest )
{
	USES_CONVERSION;

#ifdef _DEBUG
	CString tmp;
	pRequest->Write("DEBUGGING: ENTRY: SMTPServersNT<br>");
#endif
	
	// fields
	CCFXStringSet* pColumns = pRequest->CreateStringSet();
	int iServer = pColumns->AddString( "Server" );
	int iState = pColumns->AddString( "State" );
	int iDescription = pColumns->AddString( "Description" );
	
	int iBindings = pColumns->AddString( "Bindings" );
	
	int iVersion = pColumns->AddString( "Version" );
	
	int iMessageSizeLimit = pColumns->AddString( "MessageSizeLimit" );
	int iSessionSizeLimit = pColumns->AddString( "SessionSizeLimit" );
	int iMessagesPerConnectionLimit = pColumns->AddString( "MessagesPerConnectionLimit" );
	int iRecipientsPerMessageLimit = pColumns->AddString( "RecipientsPerMessageLimit" );
	
	int iBadMailDirectory = pColumns->AddString( "BadMailDirectory" );
	
	int iNonDeliveryMailTo = pColumns->AddString( "NonDeliveryMailTo" );
	int iBadMailTo = pColumns->AddString( "BadMailTo" );
	
	int iRetryInterval = pColumns->AddString( "RetryInterval" );
	
	int iDelayNotification = pColumns->AddString( "DelayNotification" );
	int iExpirationTimeout = pColumns->AddString( "ExpirationTimeout" );
	
	int iHopCount = pColumns->AddString( "HopCount" );
	int iMasqueradeDomain = pColumns->AddString( "MasqueradeDomain" );
	int iFullyQualifiedDomainName = pColumns->AddString( "FullyQualifiedDomainName" );
	int iSmartHost = pColumns->AddString( "SmartHost" );
	int iEnableReverseDnsLookup = pColumns->AddString( "EnableReverseDnsLookup" );
	CCFXQuery* pQuery = pRequest->AddQuery( get_query_variable(), pColumns );
	
	// optional
	CString strinComputer = pRequest->GetAttribute( "COMPUTER" );
	pRequest->SetVariable( "IISComputer", strinComputer );
	CString computer;
	if(	strinComputer.IsEmpty() )
		computer="LocalHost";
	else
		computer=strinComputer;
	
	//
    HRESULT hr,hr2,hrw;
	CString pathe;
	
	//
	pathe.Format("IIS://%s/SmtpSVC",computer);

#ifdef _DEBUG
	tmp.Format("DEBUGGING: Trying container %s...<br>",pathe);
	pRequest->Write(tmp);
#endif
    IADsContainer *pContainer=NULL;
    hr=ADsGetObject(A2W(pathe), IID_IADsContainer, (void**)&pContainer);
	log_COMError(__LINE__,hr);
	
	//
	if(SUCCEEDED(hr))
	{
#ifdef _DEBUG
	pRequest->Write("DEBUGGING: success<br>");
#endif

#ifdef _DEBUG
	pRequest->Write("DEBUGGING: enumerating container...<br>");
#endif

		//
		IEnumVARIANT *pEnum=NULL;
		hrw = ADsBuildEnumerator(pContainer, &pEnum); 
		log_COMError(__LINE__,hrw);
		
		//
		hr2=pContainer->Release();
		log_COMError(__LINE__,hr2);
		
		//
		if(SUCCEEDED(hrw))
		{
#ifdef _DEBUG
	pRequest->Write("DEBUGGING: success<br>");
#endif
			//
			VARIANT var;
			ULONG ulElements=1;
			
			//
			while ( (SUCCEEDED(hrw)) && (ulElements==1) )
			{
#ifdef _DEBUG
	tmp.Format("DEBUGGING: enumerating %d elements...<br>",ulElements);
	pRequest->Write(tmp);
#endif
				//
				hrw = ADsEnumerateNext(pEnum, 1, &var, &ulElements);
				log_COMError(__LINE__,hrw);
				
				//
				if(SUCCEEDED(hrw) && (ulElements==1) )
				{
#ifdef _DEBUG
	pRequest->Write("DEBUGGING: success<br>");
#endif
					//
					CString strServer;
					CString strState;
					CString strDescription;
					
					CString strBindings;
					
					CString strVersion;
					
					CString strMessageSizeLimit;
					CString strSessionSizeLimit;
					CString strMessagesPerConnectionLimit;
					CString strRecipientsPerMessageLimit;
					
					CString strBadMailDirectory;
					
					CString strNonDeliveryMailTo;
					CString strBadMailTo;
					
					CString strRetryInterval;
					
					CString strDelayNotification;
					CString strExpirationTimeout;
					
					CString strHopCount;
					CString strMasqueradeDomain;
					CString strFullyQualifiedDomainName;
					CString strSmartHost;
					CString strEnableReverseDnsLookup;
					
					//
					IADs *pADs=(IADs*)var.pdispVal;
					
					//
					BSTR bstrName;
					hr2 = pADs->get_Name(&bstrName);
					log_COMError(__LINE__,hr2);
					if(SUCCEEDED(hr2)) strServer=bstrName;
					
					BSTR bstrClass;
					hr2 = pADs->get_Class(&bstrClass);
					log_COMError(__LINE__,hr2);
					CString strClass;
					if(SUCCEEDED(hr2)) strClass=bstrClass;
					
#ifdef _DEBUG
	tmp.Format("DEBUGGING: server %s class %s...<br>",strServer,strClass);
	pRequest->Write(tmp);
#endif
					//
					if(strClass.Compare("IIsSmtpServer")==0)
					{
#ifdef _DEBUG
	pRequest->Write("DEBUGGING: success<br>");
#endif
						//
						VARIANT var;
						VariantInit(&var);
						
						//
						hr2 = pADs->Get(L"ServerState",&var);
						if(SUCCEEDED(hr2))
						{
							switch(V_INT(&var))
							{
							case MD_SERVER_STATE_STARTING: strState="Starting"; break;
							case MD_SERVER_STATE_STARTED: strState="Started"; break;
							case MD_SERVER_STATE_STOPPING: strState="Stopping"; break;
							case MD_SERVER_STATE_STOPPED: strState="Stopped"; break;
							case MD_SERVER_STATE_PAUSING: strState="Pausing"; break;
							case MD_SERVER_STATE_PAUSED: strState="Paused"; break;
							case MD_SERVER_STATE_CONTINUING: strState="Continuing"; break;
							default: strState="Unknown";
							}
						}
						VariantClear(&var);
						
						hr2 = pADs->Get(L"ServerComment",&var);
						if(SUCCEEDED(hr2)) strDescription = V_BSTR(&var) ;
						VariantClear(&var);
						
						hr2 = pADs->Get(L"ServerBindings",&var);
						if(SUCCEEDED(hr2))
						{
							VARIANTARRAYtoCString(var,strBindings,pRequest,';');
						}
						VariantClear(&var);
						
						hr2 = pADs->Get(L"SmtpServiceVersion",&var);
						if(SUCCEEDED(hr2)) strVersion.Format("%d",V_INT(&var));
						VariantClear(&var);
						
						hr2 = pADs->Get(L"MaxMessageSize",&var);
						if(SUCCEEDED(hr2)) strMessageSizeLimit.Format("%d",V_INT(&var));
						VariantClear(&var);
						hr2 = pADs->Get(L"MaxSessionSize",&var);
						if(SUCCEEDED(hr2)) strSessionSizeLimit.Format("%d",V_INT(&var));
						VariantClear(&var);
						hr2 = pADs->Get(L"MaxBatchedMessages",&var);
						if(SUCCEEDED(hr2)) strMessagesPerConnectionLimit.Format("%d",V_INT(&var));
						VariantClear(&var);
						hr2 = pADs->Get(L"MaxRecipients",&var);
						if(SUCCEEDED(hr2)) strRecipientsPerMessageLimit.Format("%d",V_INT(&var));
						VariantClear(&var);
						
						hr2 = pADs->Get(L"BadMailDirectory",&var);
						if(SUCCEEDED(hr2)) strBadMailDirectory = V_BSTR(&var) ;
						VariantClear(&var);
						
						hr2 = pADs->Get(L"SendNdrTo",&var);
						if(SUCCEEDED(hr2)) strNonDeliveryMailTo = V_BSTR(&var) ;
						VariantClear(&var);
						hr2 = pADs->Get(L"SendBadTo",&var);
						if(SUCCEEDED(hr2)) strBadMailTo = V_BSTR(&var) ;
						VariantClear(&var);
						
						hr2 = pADs->Get(L"SmtpRemoteProgressiveRetry",&var);
						if(SUCCEEDED(hr2)) strRetryInterval = V_BSTR(&var) ;
						VariantClear(&var);
						
						hr2 = pADs->Get(L"SmtpLocalDelayExpireMinutes",&var);
						if(SUCCEEDED(hr2)) strDelayNotification.Format("%d",V_INT(&var));
						VariantClear(&var);
						hr2 = pADs->Get(L"SmtpLocalNDRExpireMinutes",&var);
						if(SUCCEEDED(hr2)) strExpirationTimeout.Format("%d",V_INT(&var));
						VariantClear(&var);
						
						hr2 = pADs->Get(L"HopCount",&var);
						if(SUCCEEDED(hr2)) strHopCount.Format("%d",V_INT(&var));
						VariantClear(&var);
						hr2 = pADs->Get(L"MasqueradeDomain",&var);
						if(SUCCEEDED(hr2)) strMasqueradeDomain = V_BSTR(&var) ;
						VariantClear(&var);
						hr2 = pADs->Get(L"FullyQualifiedDomainName",&var);
						if(SUCCEEDED(hr2)) strFullyQualifiedDomainName = V_BSTR(&var) ;
						VariantClear(&var);
						hr2 = pADs->Get(L"SmartHost",&var);
						if(SUCCEEDED(hr2)) strSmartHost = V_BSTR(&var) ;
						VariantClear(&var);
						hr2 = pADs->Get(L"EnableReverseDnsLookup",&var);
						if(SUCCEEDED(hr2)) strEnableReverseDnsLookup.Format("%d",abs(V_BOOL(&var)));
						VariantClear(&var);
						
						//
						int iRow = pQuery->AddRow();
						pQuery->SetData( iRow, iServer, strServer );
						pQuery->SetData( iRow, iState, strState );
						pQuery->SetData( iRow, iDescription, strDescription );
						
						pQuery->SetData( iRow, iBindings, strBindings );
						
						pQuery->SetData( iRow, iVersion, strVersion );
						
						pQuery->SetData( iRow, iMessageSizeLimit, strMessageSizeLimit );
						pQuery->SetData( iRow, iSessionSizeLimit, strSessionSizeLimit );
						pQuery->SetData( iRow, iMessagesPerConnectionLimit, strMessagesPerConnectionLimit );
						pQuery->SetData( iRow, iRecipientsPerMessageLimit, strRecipientsPerMessageLimit );
						
						pQuery->SetData( iRow, iBadMailDirectory, strBadMailDirectory );
						
						pQuery->SetData( iRow, iNonDeliveryMailTo, strNonDeliveryMailTo );
						pQuery->SetData( iRow, iBadMailTo, strBadMailTo );
						
						pQuery->SetData( iRow, iRetryInterval, strRetryInterval );
						
						pQuery->SetData( iRow, iDelayNotification, strDelayNotification );
						pQuery->SetData( iRow, iExpirationTimeout, strExpirationTimeout );
						
						pQuery->SetData( iRow, iHopCount, strHopCount );
						pQuery->SetData( iRow, iMasqueradeDomain, strMasqueradeDomain );
						pQuery->SetData( iRow, iFullyQualifiedDomainName, strFullyQualifiedDomainName );
						pQuery->SetData( iRow, iSmartHost, strSmartHost );
						pQuery->SetData( iRow, iEnableReverseDnsLookup, strEnableReverseDnsLookup );
					}
					
					//
					hr2=pADs->Release();
					log_COMError(__LINE__,hr2);
					
					//
					SysFreeString(bstrClass);
					SysFreeString(bstrName);
				}

			}
		}
		//
		hr2 = ADsFreeEnumerator(pEnum);
		log_COMError(__LINE__,hr2);
	}
#ifdef _DEBUG
	pRequest->Write("DEBUGGING: EXIT: SMTPServersNT<br>");
#endif
}
Пример #6
0
int main(int argc, char* argv[])
{
	IADsContainer *pSchema=NULL;
	HRESULT hr;

	CoInitialize(NULL);

	hr = ADsGetObject(L"WinNT://INDEPENDENCE/Schema", IID_IADsContainer, (void**) &pSchema );

	if ( !SUCCEEDED(hr) )
	{
		return hr;
	}


	////////////// Enumerate Schema objects ///////////////////////////////////
	IEnumVARIANT *pEnum = NULL;
	hr = ADsBuildEnumerator( pSchema, &pEnum );
	pSchema->Release(); // no longer needed, since we have the enumerator already
	
	if ( SUCCEEDED(hr) )
	{
		VARIANT var;
		ULONG lFetch;
		IADs *pChild=NULL;
		VariantInit(&var);
		
		while( SUCCEEDED(ADsEnumerateNext( pEnum, 1, &var, &lFetch )) && lFetch == 1 )
		{
			hr = V_DISPATCH(&var)->QueryInterface( IID_IADs, (void**) &pChild );
			if ( SUCCEEDED(hr) )
			{
				BSTR bstrName;
				BSTR bstrClass;
				// Get more information on the child classes
				pChild->get_Name(&bstrName);
				pChild->get_Class(&bstrClass);
				
				printf("%S\t\t(%S)\n", bstrName, bstrClass );
				
				// Clean-up
				SysFreeString(bstrName);
				SysFreeString(bstrClass);
				
				pChild->Release();
			}
			VariantClear(&var);
		}
	}

              //Release the enumerator.
              if (pEnum != NULL) 
              {
                  ADsFreeEnumerator(pEnum);
              }


	CoUninitialize();



	return 0;
}