Brendan, You were almost correct... try this (note the additional parens around the negated expression):
(&(objectClass=user)(objectCategory=person)(sn=*)(!(ou=*Contacts*));samAccou ntName,name,company,telephoneNumber,AdsPath;subtree http://www.ietf.org/rfc/rfc2251.txt?number=2251 has the complete description of LDAP search filter syntax. Gil Kirkpatrick Chief Technology Officer, NetPro Author of "Active Directory Programming" from MacMillan Got eBook? Get your free Active Directory Troubleshooting eBook at: http://www.netpro.com/ebook -----Original Message----- From: Stephens, Brendan [mailto:[EMAIL PROTECTED]] Sent: Friday, May 24, 2002 7:22 AM To: ''[EMAIL PROTECTED]' ' Subject: [ActiveDir] Searching LDAP If anyone is familiar with LDAP syntax, I could use some help on this one... Our directory structure is separated into OU's, and I am trying to filter a specific OU out of the picture... I can pull the users by using the following syntax for ADO... strSQL = "<LDAP://" & Domain &">;(&(objectClass=user)(objectCategory=person)(sn=*);samAccountName,name,co mpany,telephoneNumber,AdsPath;subtree" But how do I filter out an OU? (Contacts) I have tried: strSQL = "<LDAP://" & Domain &">;(&(objectClass=user)(objectCategory=person)(sn=*)(!ou=*Contacts*);samAcc ountName,name,company,telephoneNumber,AdsPath;subtree" and a couple of other variants on this, but to no avail... Any suggestions or guru's on this matter? Brendan Stephens Web Applications Developer Tech-Advances List info : http://www.activedir.org/mail_list.htm List FAQ : http://www.activedir.org/list_faq.htm List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/ List info : http://www.activedir.org/mail_list.htm List FAQ : http://www.activedir.org/list_faq.htm List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
