C# - Filtering a DirectorySearcher for groupmembers

半城伤御伤魂 提交于 2019-12-25 07:59:06

问题


my issue is about filtering members of a specific group to be not shown in the userlist. So far to that, this is my code to filter them out so far:

searcher.Filter = string.Format("(&(cn=*{0}*)(objectCategory=person)(objectClass=user)(!(adminCount=1))(!(cn=*Admin*)))",SuchfeldNachName.Text).Replace("**","*");

This is how I am trying to filter it right now. Obviously, I am trying to not show admins in the userlist. But thats not a fine solution for me, because in the final state, I want it to filter out four specific Active Directory groups.

These are the four groups I want to filter out:

  • Domain Admins
  • Enterprise Admins
  • Policy Creator Owner
  • Schema Admins

Now my question:

Is there a possible way to filter out the groupID's? So that the users in these groups are not shown in my userlist.

My idea was something like

(!(primaryGroupID= 512)) 

Second part of my question: Is there a list for all the group ID's?

Appreciate help in advance!

来源:https://stackoverflow.com/questions/40932638/c-sharp-filtering-a-directorysearcher-for-groupmembers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!