Microsoft KB Archive/306799

= How To Hide/Unhide Distribution Group Membership =

Article ID: 306799

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft Collaboration Data Objects for Exchange Management 1.1
 * Microsoft Exchange 2000 Server Standard Edition

-



This article was previously published under Q306799



SUMMARY
You can hide and unhide Windows 2000 distribution group membership programmatically by using CDOEXM and the IDistributionList::HideDLMembership method. The only supported methods of hiding and unhiding group membership are by using CDOEXM, the Users and Computers snap-in, or the Active Directory Connector (ADC).



MORE INFORMATION
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(&quot;LDAP://CN=MyDL,CN=Users,DC=MyDomain&quot;) Set objDistList = objAD objDistList.HideDLMembership = True objAD.SetInfo Set objAD = Nothing Set objDistList = Nothing End Sub

Microsoft Visual C++ Sample

 * 1) include &quot;stdio.h&quot;
 * 2) include &quot;activeds.h&quot;

// Importing the libraries required to use CDOEXM
 * 1) import  no_namespace raw_interfaces_only exclude(&quot;IDataSource2&quot;)

int main(void) {   // Declare variables HRESULT hr; LPWSTR strDLLDAPPath; IADsUser *pDLobj = NULL; IDistributionList *pDL = NULL; BOOL Setit = -1;

//Set the LDAP path strDLLDAPPath =          L&quot;LDAP://MyServer/CN=test4dl,CN=Users,DC=MyDomain,DC=com&quot;;

//Initialize COM hr = CoInitialize(NULL); if (FAILED(hr)) { wprintf(L&quot;Failed to CoInitialize: 0x%x\n&quot;, hr); return hr; }

//Bind to the existing DL using ADSI hr = ADsGetObject(strDLLDAPPath, IID_IADs, (void**)&pDLobj); if (FAILED(hr)) { wprintf(L&quot;Failed to get IADs: 0x%x\n&quot;, 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&quot;QueryInterface of IDistributionList failed!\n&quot;); pDLobj->Release; pDL->Release; CoUninitialize; return hr; }

//Set the hideDLMembership attribute hr = pDL->put_HideDLMembership(Setit); if (!SUCCEEDED(hr)) {       wprintf(L&quot;put_HideDLMembership failed!\n&quot;); 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&quot;SetInfo failed!\n&quot;); pDLobj->Release; pDL->Release; CoUninitialize; return hr; }

//Cleanup and uninitialize COM pDLobj->Release; pDL->Release; pDLobj = NULL; pDL = NULL; CoUninitialize; return 0; }



This behavior is by design.This has been bugged and resolved as By Design.

