public string GetUsers() { List <LdapEntry> ldapUsers = DtypUtility.GetUsers(domainName, adminName, adminPassword); List <User> users = new List <User>(); foreach (LdapEntry userEntry in ldapUsers) { string userName = userEntry.GetAttribute("name").StringValue; byte[] userSidBinary = userEntry.GetAttribute("objectSid").ByteValue; _SID userSid = TypeMarshal.ToStruct <_SID>(userSidBinary); User user = new User(); user.Name = userName; user.Sid = userSid; users.Add(user); } return(JsonSerializer.Serialize(users, serializerOptions)); }