We help IT Professionals succeed at work.

ADModify LDAP Query Help

126 Views
Last Modified: 2017-03-24
Hi,

i am trying to search all users that do not contain a proxyaddress but seemed to be getting an invalid query error, any help would be appreciated.

(objectClass=user)(!(proxyAddresses:=*@DOMAINNAME.com)))
Comment
Watch Question

Kevin StanushApplication Developer

Commented:
Try:

(&(objectCategory=user)(!proxyAddresses=*))

For a visual way to do this, try Hyena (www.systemtools.com).  It will let you do this interactively by just running a query, and then you can sort on the ProxyAddresses column.

Video on modifying AD queries is here:

https://www.youtube.com/watch?v=1ONAhKyB61g

Author

Commented:
(&(objectCategory=user)(!proxyAddresses=*@DomainName.com))

also returning contacts :(
Kevin StanushApplication Developer

Commented:
Sorry, just replace objectcategory=user to objectclass=user.  If you have a huge AD environment, we can optimize it with objectcategory some, but its probably not worth it.

Author

Commented:
that worked :) could we also include "and" contains(@DOMAINNAME2)

summary

Must be user
Does not contain
3*filter Contains"@Domainname2.com"
PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
This Guy is A Wizard!
Kevin StanushApplication Developer

Commented:
Glad I could help.