Solved

Active Directory LDAP Custom Query for mail distribution group

Posted on 2011-03-17
17
1,316 Views
Last Modified: 2012-05-11
Dear experts!

I would like to know how I need to define an Active Directory LDAP query for mail distribution.

The following is the situation:

I have an OU=TEST1 and a Sub-OU=TEST2

In the query I posted, I select all members from ou TEST2. However, I need to also select all members from the above ou TEST1 where the user description is like 'IT DEPARTMENT'.
This is due to the fact that in our environment I cannot have one and the same user in multiple OUs.

Can you please show me how I can select all members from TEST2 and union the ones from TEST1 where the user description field contains the criteria '%IT%'!

It wouldn't be a problem is SQL but LDAP is so much different! :-)

Many thanks for your help! I appreciate your effort!

Best regards,

skahlert2010
(&(!cn=SystemMailbox{*})(&(&(&(mailnickname=*](|(&(objectCategory=person)(objectClass=user)(!(useraccountcontrol:1.2.840.113556.1.2.803:=2))(|(homeMDB=*)(msExchHomeServerName=*))) )))))

Open in new window

0
Comment
Question by:skahlert2010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 12

Expert Comment

by:Navdeep
ID: 35163675
Hi,

what is the purpose behind this query? Why you need such a query?

are you trying to create distribution list for mail enabled users ?
0
 

Author Comment

by:skahlert2010
ID: 35165669
Hello v-2nas! Exactly! You're right! I am trying to create a distribution list for all users in different organizational units. Like I said, All members of an OU TEST2 and the ones in the upper OU TEST1 that have a certain flag in their description field.

The query has to be customized since the wizard doesn't allow me to formulate such a complex statement.

Hope you or somebody else can assist me?!

Rgds,
skahlert
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35165770
Why don't you create one mail enabled distribution list and make all the users from OU1 and OU2 member of it.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:skahlert2010
ID: 35166746
Because Not all Users of ou 2 should Be members of the Distribution List! Is my Artemis with the query impossible?  I guess it should Be an Option of i knew how to Second it!
!
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35167048
Thats what i am saying you create a distribution group and manually add the users u want

Or r u trying query base dist group due to dynamic n large user base
0
 

Author Comment

by:skahlert2010
ID: 35167242
Sorry I misunderstood you at First! My Base Group contains too many Users to Select them all manually! It is a considerable administrative effort, which I like to avoid with a dynamic query!
0
 

Author Comment

by:skahlert2010
ID: 35172045
Nobody having an example or idea for such a query with an "or" option?
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35173865
I will do it for you. It weekend right now ;)
0
 

Author Comment

by:skahlert2010
ID: 35174740
Good morning v-2nas!

You're right it is weekend! I could'nt stop thinking about this issue, whereas I should infact just enjoy the weekend as you recommend!

 I wish you a great Sunday and am looking forward to your answer!

Take care,

skahlert2010
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35178523
Hi,

what is your os and exchange version
0
 

Author Comment

by:skahlert2010
ID: 35178551
Hi v-2-nas!
Great yoU're back at it! I have already experimented a little bit today to no avail though!
I have Active Directory Users and Computers v.5.2.3790.3959 and Windows Server 2003. Exchange is 2003 as far as I know!
0
 
LVL 12

Accepted Solution

by:
Navdeep earned 500 total points
ID: 35184030
Hi,

Please check this online article for query based DN
http://www.petri.co.il/working_with_query_based_distribution_groups_in_exchange_2003.htm

I have tried with Ex2007. Works fine, for exchange 2003 i need to setup a new lab. Just see, i believe it should work.
0
 

Author Comment

by:skahlert2010
ID: 35188346
Thank you v-2-nas for your help and for posting this excellent how-to!

I finally got a little further and the query is working to a certain extent.

However, I would like to search for all users whose distinguishedName contains the OU "abt_neu".
This part is not working at all and doesn't yield any output. Is there a way to query a special OU and return all its users.

The wildcard operator for the dn doesn't seem to work!

Brgds,

skahlert2010

(&(!cn=SystemMailbox{*})(&(&(& (mailnickname=*) 
(| (&(objectCategory=person)(objectClass=user)
(!(useraccountcontrol:1.2.840.113556.1.4.803:=2))
(|(homeMDB=*)(msExchHomeServerName=*))
(|(memberOf=*CN=lwf-gr-gg-1,OU=abt_neu,OU=groups,OU=LWF,DC=my,DC=domain,DC=com)
((description=*StVPrae*))) ) )))))

Open in new window

0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35191644
so basically now you want to search under that particular ou, modify the query to include searchroot starting from abt_neu
0
 

Author Comment

by:skahlert2010
ID: 35192171
Thanks four replying once more, but could you post a short example of how to include "searchroot" before I close the question and award you the credits?

You've done a gret job and I really appreciate it!

Best regards,

skahlert2010
0
 
LVL 12

Expert Comment

by:Navdeep
ID: 35192710
Thx for you compliments. can you post a screenshot where you have added the above ldap code. If you check the the link that i have posted. It selects the searchroot using gui.

as you using msExchDynamicDistributionList
0
 

Author Closing Comment

by:skahlert2010
ID: 35213532
I just wanted to say thanks for your help and close this question! Due to your help I found a solution that works for me! Thanks a lot!

Best regards,

skahlert2010
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question