Recipe 5.13. Creating Query-Based Distribution GroupsProblemYou want to create a mail-enabled distribution group that automatically updates its membership based on rules you specify. SolutionUsing a graphical user interface
Once you've chosen the filter specifications that you want to use, click Next, and then click Finish. Figure 5-5. Choosing the scope and extent of the QDG filter using this dialogUsing VBScript' This code creates a new query-based distribution group in the Users ' container. The QDG contains all users who have Exchange mailboxes. ' ------ SCRIPT CONFIGURATION ------ strDCName = "<serverName>" ' e.g., "CONT-EXBE01" strContainer= "<container>" ' e.g., "CN=users,dc=robichaux, dc=net" strQDGName = "<name>" 'e.g., "Mail Users" strDomain = "@<domain>" ' e.g., "@robichaux.net" strFilter = "(&(!cn=SystemMailbox{*})(& (mailnickname=*)" &_ "(|&(objectCategory=person) (objectClass=user)" &_ "(|(homeMDB=*)(msExchHomeServerName=*))) )))" ' ------ END CONFIGURATION --------- Set objContainer = GetObject("LDAP://" & strDCName & "/" & strContainer) Set objQDG = objContainer.Create("msExchDynamicDistributionList", _ "CN=" & strQDGName) With objQDG .Put "msExchDynamicDLFilter", strFilter .Put "displayName", strQDGName .Put "mailNickname", strQDGName .Put "reportToOriginator", True .Put "proxyAddresses", "SMTP:" & strQDGName & strDomain .Put "legacyExchangeDN", "/o=<orgName>/ou=<adminGrp>/cn=Recipients/cn=" & strQDGName ' e.g. "/o=Robichaux and Associates/ou=First Administrative ' Group/cn=Recipients/cn=" & strQDGName .put "msExchDynamicDLBaseDN", strContainer .Put "systemFlags", 1610612736 .SetInfo End With Wscript.echo "Created QDG " & strQDGName DiscussionQuery-based distribution groups are probably better known by their original name: dynamic DLs. The idea behind QDGs is that you should be able to define some set of search criteria that can be used to populate a DL, and that when objects' properties change such that they should be included in, or excluded from, the DL, the DL should automatically be updated somehow. When you create a QDG, you must specify an LDAP filter that selects the objects you want. The filter in the listing above is the one generated by the ESM GUI when you create a new QDG; notice that it excludes items named "System Mailbox" and any item that isn't a user or that doesn't have an Exchange home server defined. You can specify more complex LDAP filters to selectively limit QDG membership to particular OUs or subgroups of users. One thing to bear in mind when designing your QDG queries is that the query will be executed each time the QDG is expanded. Each message sent to the QDG will cause an expansion, depending on where the sender is and which server is responsible for the expansion process. For complex queries, or for large result sets, the performance impact on your GCs and Exchange servers can be significant. You can work around this to an extent by designating a specific expansion server for the QDG (or any other DG); this doesn't reduce the load, but it does let you control where it goes. Another very important aspect of QDGs is that each has a legacyExchangeDN attribute, just like a mailbox. Also just like mailboxes, the legacyExchangeDN value for each QDG must be unique in the forest. If you create multiple QDGs with the same name (say, one in each domain of a multidomain forest), you must be certain that the legacyExchangeDN values for each QDG are distinct. See AlsoMS KB 822897 (How to Troubleshoot Query-Based Distribution Groups) and MS KB 839949 (Troubleshooting mail transport and distribution groups in Exchange 2000 Server and in Exchange Server 2003) |