public string GetGroupMembers(string groupName) { List <LdapEntry> ldapGroupMembers = DtypUtility.GetGroupMembers(domainName, groupName, adminName, adminPassword); List <GroupMember> groupMembers = new List <GroupMember>(); foreach (LdapEntry groupEntry in ldapGroupMembers) { string groupMemberName = groupEntry.GetAttribute("name").StringValue; byte[] groupMemberSidBinary = groupEntry.GetAttribute("objectSid").ByteValue; string groupMemberObjectClass = groupEntry.GetAttribute("objectClass").StringValue; string groupMemberPrincipalSource = "ActiveDirectory"; _SID groupMemberSid = TypeMarshal.ToStruct <_SID>(groupMemberSidBinary); GroupMember groupMember = new GroupMember(); groupMember.Name = groupMemberName; groupMember.Sid = groupMemberSid; groupMember.ObjectClass = groupMemberObjectClass; groupMember.PrincipalSource = groupMemberPrincipalSource; groupMembers.Add(groupMember); } return(JsonSerializer.Serialize(groupMembers, serializerOptions)); }