From a34534eb626b65e5754a030c0225a27edd0cf673 Mon Sep 17 00:00:00 2001 From: anomny Date: Sat, 4 Oct 2025 10:38:19 +0200 Subject: [PATCH] Fix build errors --- src/Controllers/GroupsController.cs | 25 ++++++++++++------------- src/Controllers/UsersController.cs | 21 ++++++++++----------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/Controllers/GroupsController.cs b/src/Controllers/GroupsController.cs index 2debc38..0ca257c 100644 --- a/src/Controllers/GroupsController.cs +++ b/src/Controllers/GroupsController.cs @@ -66,19 +66,18 @@ public class GroupsController : Controller { description ??= JsonSerializer.Serialize(new GroupPermissions() {Permissions = []}); - LdapAttributeSet attributeSet = - [ - new LdapAttribute("objectClass", "posixGroup"), - new LdapAttribute("objectClass", "top"), - new LdapAttribute("cn", cn), - new LdapAttribute("gidNumber", gidNumber), - new LdapAttribute("description", - JsonSerializer.Serialize( - new GroupPermissions() - { - Permissions = [.. permissions] - })), - ]; + var attributeSet = new LdapAttributeSet(); + attributeSet.Add(new LdapAttribute("objectClass", "posixGroup")); + attributeSet.Add(new LdapAttribute("objectClass", "top")); + attributeSet.Add(new LdapAttribute("cn", cn)); + attributeSet.Add(new LdapAttribute("gidNumber", gidNumber)); + attributeSet.Add(new LdapAttribute( + "description", + JsonSerializer.Serialize(new GroupPermissions() + { + Permissions = [.. permissions] + }))); + await _ldap.CreateGroup(cn, attributeSet); return true; } diff --git a/src/Controllers/UsersController.cs b/src/Controllers/UsersController.cs index 5430b89..4251149 100644 --- a/src/Controllers/UsersController.cs +++ b/src/Controllers/UsersController.cs @@ -74,17 +74,16 @@ public class UsersController : Controller byte[] hashedPassword = SHA256.HashData(passwordBytes); userPassword = "{SHA256}" + Convert.ToBase64String(hashedPassword); } - LdapAttributeSet attributeSet = - [ - new LdapAttribute("objectClass", "inetOrgPerson"), - new LdapAttribute("cn", cn), - new LdapAttribute("sn", sn), - new LdapAttribute("title", title), - new LdapAttribute("uid", uid), - new LdapAttribute("jpegPhoto", jpegPhoto), - new LdapAttribute("description", description), - new LdapAttribute("userPassword", userPassword) - ]; + + LdapAttributeSet attributeSet = new LdapAttributeSet(); + attributeSet.Add(new LdapAttribute("objectClass", "inetOrgPerson")); + attributeSet.Add(new LdapAttribute("cn", cn)); + attributeSet.Add(new LdapAttribute("sn", sn)); + attributeSet.Add(new LdapAttribute("title", title)); + attributeSet.Add(new LdapAttribute("uid", uid)); + attributeSet.Add(new LdapAttribute("jpegPhoto", jpegPhoto)); + attributeSet.Add(new LdapAttribute("description", description)); + attributeSet.Add(new LdapAttribute("userPassword", userPassword)); await _ldap.CreateUser(uid, attributeSet); return true; }