Get group members in replication metadata from directory services namespace


  • I'm trying to get a groups member list or even the members attribute from AttributeMetadata Class [1] like the following:

    var directoryContext = new DirectoryContext(DirectoryContextType.DirectoryServer, "dc", "user", "pw");
    var metadata = DomainController.GetDomainController(directoryContext).GetReplicationMetadata("groupDN");
    foreach (AttributeMetadata attribute in metaData.Values)
      string name = attribute.Name

    The problem is that the members list and the multi value attribute 'members' are no part of the metaData.Values collection. Does anyone know how to get them? Or is there an another way to get the members metadata?

    [1] AttribteMetdata Class;k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5);k(DevLang-csharp)&rd=true

    Thursday, April 13, 2017 6:25 AM


All replies

  • Hi TheLeprechaunsMadeMeDoIT,

    Thank you for posting here.

    For your question, do you mean you want to get the members in Directory Service? What members metadata you want to get? When you get the user name in the list and then you want to get the other information of the user name? Like email address or Home directory or other things?

    If you wanna do that, please try the following code.

     public static void GetAD()
                List<string> userNameList = new List<string>();
                using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
                    using (UserPrincipal user = new UserPrincipal(context))
                        using (PrincipalSearcher searcher = new PrincipalSearcher(user))
                            foreach (System.DirectoryServices.AccountManagement.UserPrincipal result in searcher.FindAll())
                                userNameList.Add(result.Name);//put all the users in the list
                                Console.WriteLine(result.Name);//or you could output all the user name

    I hope this would be helpful.

    If I misunderstanding what you want, pleas feel free to contact us.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, April 14, 2017 6:00 AM
  • The answer is to query the msds-replvaluemetadata attribute from ad group object. Member meta data is stored there.
    Tuesday, April 18, 2017 8:13 AM
  • I just wanted to get members replication meta informaton. Thanks for your help, i found an answer - check below
    Tuesday, April 18, 2017 8:17 AM