mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Use collection initializers
This commit is contained in:
@@ -36,30 +36,28 @@ public class AssetsController : Controller
|
||||
{
|
||||
var ownerDn = $"uid={assetModel.Owner},ou=people,dc=example,dc=com";
|
||||
|
||||
var attributeSet = new LdapAttributeSet();
|
||||
attributeSet.Add(new LdapAttribute("objectClass", new[] {
|
||||
"top",
|
||||
"device",
|
||||
"extensibleObject"
|
||||
}));
|
||||
attributeSet.Add(new LdapAttribute("cn", assetModel.Cn));
|
||||
attributeSet.Add(new LdapAttribute("serialNumber", assetModel.SerialNumber));
|
||||
attributeSet.Add(new LdapAttribute("l", assetModel.Location));
|
||||
attributeSet.Add(new LdapAttribute("owner", ownerDn));
|
||||
attributeSet.Add(new LdapAttribute("name", assetModel.Name));
|
||||
attributeSet.Add(new LdapAttribute(
|
||||
LdapAttributeSet attributeSet =
|
||||
[
|
||||
new LdapAttribute("objectClass", new[] {"top", "device", "extensibleObject"}),
|
||||
new LdapAttribute("cn", assetModel.Cn),
|
||||
new LdapAttribute("serialNumber", assetModel.SerialNumber),
|
||||
new LdapAttribute("l", assetModel.Location),
|
||||
new LdapAttribute("owner", ownerDn),
|
||||
new LdapAttribute("name", assetModel.Name),
|
||||
new LdapAttribute(
|
||||
"description",
|
||||
JsonSerializer.Serialize(new AssetDescription()
|
||||
{
|
||||
Type = assetModel.Description.Type,
|
||||
Type = assetModel.Description!.Type,
|
||||
Purchase = new AssetPurchase
|
||||
{
|
||||
PurchasedAt = assetModel.Description.Purchase.PurchasedAt,
|
||||
PurchasedAt = assetModel.Description.Purchase!.PurchasedAt,
|
||||
PurchaseDate = assetModel.Description.Purchase.PurchaseDate,
|
||||
PurchaseValue = assetModel.Description.Purchase.PurchaseValue
|
||||
}
|
||||
})
|
||||
));
|
||||
)
|
||||
];
|
||||
|
||||
await _ldap.CreateAsset(attributeSet);
|
||||
|
||||
|
||||
@@ -66,17 +66,19 @@ public class GroupsController : Controller
|
||||
{
|
||||
description ??= JsonSerializer.Serialize(new GroupPermissions() {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(
|
||||
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]
|
||||
})));
|
||||
}))
|
||||
];
|
||||
|
||||
await _ldap.CreateGroup(cn, attributeSet);
|
||||
return true;
|
||||
|
||||
@@ -75,15 +75,17 @@ public class UsersController : Controller
|
||||
userPassword = "{SHA256}" + Convert.ToBase64String(hashedPassword);
|
||||
}
|
||||
|
||||
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));
|
||||
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),
|
||||
];
|
||||
await _ldap.CreateUser(uid, attributeSet);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user