The sample provided in this section demonstrates how to use
the
IDistributionList::HideDLMembership method to hide the distribution group membership list. You must
run this code authenticated in the same domain that the Exchange 2000 server is
in.
Calling
IDistributionList::HideDLMembership from outside the domain is not supported.
Calling
IDistributionList::HideDLMembership from any scripting language is not supported unless the call is
wrapped in a COM object. For more information, see below.
Although
use of
IDistributionList::HideDLMembership to hide membership will set
reportToOriginator,
oofReplyToOriginator, and
reportToOwner properties to
False, unhiding the membership will not modify these properties. If you
want to change these, you must set them yourself.
Microsoft Visual Basic Sample
Private Sub Command1_Click()
Dim objDistList As CDOEXM.IDistributionList
Dim objAD As IADsGroup
'NOTE: using OpenDSObject here is unsupported
Set objAD = GetObject("LDAP://CN=MyDL,CN=Users,DC=MyDomain")
Set objDistList = objAD
objDistList.HideDLMembership = True
objAD.SetInfo
Set objAD = Nothing
Set objDistList = Nothing
End Sub
Microsoft Visual C++ Sample
#include "stdio.h"
#include "activeds.h"
// Importing the libraries required to use CDOEXM
#import <C:\Program Files\Exchsrvr\BIN\cdoexm.dll> no_namespace raw_interfaces_only exclude("IDataSource2")
int main(void)
{
// Declare variables
HRESULT hr;
LPWSTR strDLLDAPPath;
IADsUser *pDLobj = NULL;
IDistributionList *pDL = NULL;
BOOL Setit = -1;
//Set the LDAP path
strDLLDAPPath = L"LDAP://MyServer/CN=test4dl,CN=Users,DC=MyDomain,DC=com";
//Initialize COM
hr = CoInitialize(NULL);
if (FAILED(hr)) {
wprintf(L"Failed to CoInitialize: 0x%x\n", hr);
return hr;
}
//Bind to the existing DL using ADSI
hr = ADsGetObject(strDLLDAPPath, IID_IADs, (void**)&pDLobj);
if (FAILED(hr)) {
wprintf(L"Failed to get IADs: 0x%x\n", hr);
pDLobj->Release();
CoUninitialize();
return hr;
}
//Query for the IDistributionList Interface using the IADs object
hr = pDLobj->QueryInterface(__uuidof(IDistributionList), (void**)&pDL);
if (!SUCCEEDED(hr))
{
wprintf(L"QueryInterface of IDistributionList failed!\n");
pDLobj->Release();
pDL->Release();
CoUninitialize();
return hr;
}
//Set the hideDLMembership attribute
hr = pDL->put_HideDLMembership(Setit);
if (!SUCCEEDED(hr))
{
wprintf(L"put_HideDLMembership failed!\n");
pDLobj->Release();
pDL->Release();
CoUninitialize();
return hr;
}
//Apply changes made to the cache back to the Active Directory
hr = pDLobj->SetInfo();
if (!SUCCEEDED(hr))
{
wprintf(L"SetInfo failed!\n");
pDLobj->Release();
pDL->Release();
CoUninitialize();
return hr;
}
//Cleanup and uninitialize COM
pDLobj->Release();
pDL->Release();
pDLobj = NULL;
pDL = NULL;
CoUninitialize();
return 0;
}