public string GetGroups() { List <LdapEntry> ldapGroups = DtypUtility.GetGroups(domainName, adminName, adminPassword); List <Group> groups = new List <Group>(); foreach (LdapEntry groupEntry in ldapGroups) { string groupName = groupEntry.GetAttribute("name").StringValue; byte[] groupSidBinary = groupEntry.GetAttribute("objectSid").ByteValue; _SID groupSid = TypeMarshal.ToStruct <_SID>(groupSidBinary); Group group = new Group(); group.Name = groupName; group.Sid = groupSid; groups.Add(group); } return(JsonSerializer.Serialize(groups, serializerOptions)); }