Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How To Hide/Unhide Distribution Group Membership


View products that this article applies to.

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).

↑ Back to the top


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("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;
   }

				

↑ Back to the top


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

↑ Back to the top


References

For additional information about programmatically starting the Recipient Update Service (RUS), click the following article number to view the article in the Microsoft Knowledge Base:
306866 How To Programmatically Start the RUS
For additional information about using the ADSI and CDOEXM interfaces, click the following article number to view the article in the Microsoft Knowledge Base:
306867 PRB: Calling ADSI and CDOEXM Methods from Scripting Languages
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
253827 XADM: How Exchange Hides Group Membership in Active Directory
287137 XADM: Recipient Update Service Stops Responding with Event 8022
299250 XADM: When You Reveal the Membership of a Previously Hidden Group, the Group Stays Hidden

↑ Back to the top


Keywords: KB306799, kbhowto, kbdswadsi2003swept, kbdswadsi2003swept

↑ Back to the top

Article Info
Article ID : 306799
Revision : 6
Created on : 2/23/2007
Published on : 2/23/2007
Exists online : False
Views : 493