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 ownerDn = $"uid={assetModel.Owner},ou=people,dc=example,dc=com";
|
||||||
|
|
||||||
var attributeSet = new LdapAttributeSet();
|
LdapAttributeSet attributeSet =
|
||||||
attributeSet.Add(new LdapAttribute("objectClass", new[] {
|
[
|
||||||
"top",
|
new LdapAttribute("objectClass", new[] {"top", "device", "extensibleObject"}),
|
||||||
"device",
|
new LdapAttribute("cn", assetModel.Cn),
|
||||||
"extensibleObject"
|
new LdapAttribute("serialNumber", assetModel.SerialNumber),
|
||||||
}));
|
new LdapAttribute("l", assetModel.Location),
|
||||||
attributeSet.Add(new LdapAttribute("cn", assetModel.Cn));
|
new LdapAttribute("owner", ownerDn),
|
||||||
attributeSet.Add(new LdapAttribute("serialNumber", assetModel.SerialNumber));
|
new LdapAttribute("name", assetModel.Name),
|
||||||
attributeSet.Add(new LdapAttribute("l", assetModel.Location));
|
new LdapAttribute(
|
||||||
attributeSet.Add(new LdapAttribute("owner", ownerDn));
|
"description",
|
||||||
attributeSet.Add(new LdapAttribute("name", assetModel.Name));
|
JsonSerializer.Serialize(new AssetDescription()
|
||||||
attributeSet.Add(new LdapAttribute(
|
|
||||||
"description",
|
|
||||||
JsonSerializer.Serialize(new AssetDescription()
|
|
||||||
{
|
|
||||||
Type = assetModel.Description.Type,
|
|
||||||
Purchase = new AssetPurchase
|
|
||||||
{
|
{
|
||||||
PurchasedAt = assetModel.Description.Purchase.PurchasedAt,
|
Type = assetModel.Description!.Type,
|
||||||
PurchaseDate = assetModel.Description.Purchase.PurchaseDate,
|
Purchase = new AssetPurchase
|
||||||
PurchaseValue = assetModel.Description.Purchase.PurchaseValue
|
{
|
||||||
}
|
PurchasedAt = assetModel.Description.Purchase!.PurchasedAt,
|
||||||
})
|
PurchaseDate = assetModel.Description.Purchase.PurchaseDate,
|
||||||
));
|
PurchaseValue = assetModel.Description.Purchase.PurchaseValue
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
await _ldap.CreateAsset(attributeSet);
|
await _ldap.CreateAsset(attributeSet);
|
||||||
|
|
||||||
|
|||||||
@@ -66,17 +66,19 @@ public class GroupsController : Controller
|
|||||||
{
|
{
|
||||||
description ??= JsonSerializer.Serialize(new GroupPermissions() {Permissions = []});
|
description ??= JsonSerializer.Serialize(new GroupPermissions() {Permissions = []});
|
||||||
|
|
||||||
var attributeSet = new LdapAttributeSet();
|
LdapAttributeSet attributeSet =
|
||||||
attributeSet.Add(new LdapAttribute("objectClass", "posixGroup"));
|
[
|
||||||
attributeSet.Add(new LdapAttribute("objectClass", "top"));
|
new LdapAttribute("objectClass", "posixGroup"),
|
||||||
attributeSet.Add(new LdapAttribute("cn", cn));
|
new LdapAttribute("objectClass", "top"),
|
||||||
attributeSet.Add(new LdapAttribute("gidNumber", gidNumber));
|
new LdapAttribute("cn", cn),
|
||||||
attributeSet.Add(new LdapAttribute(
|
new LdapAttribute("gidNumber", gidNumber),
|
||||||
"description",
|
new LdapAttribute(
|
||||||
JsonSerializer.Serialize(new GroupPermissions()
|
"description",
|
||||||
{
|
JsonSerializer.Serialize(new GroupPermissions()
|
||||||
Permissions = [.. permissions]
|
{
|
||||||
})));
|
Permissions = [.. permissions]
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
|
||||||
await _ldap.CreateGroup(cn, attributeSet);
|
await _ldap.CreateGroup(cn, attributeSet);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -75,15 +75,17 @@ public class UsersController : Controller
|
|||||||
userPassword = "{SHA256}" + Convert.ToBase64String(hashedPassword);
|
userPassword = "{SHA256}" + Convert.ToBase64String(hashedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapAttributeSet attributeSet = new LdapAttributeSet();
|
LdapAttributeSet attributeSet =
|
||||||
attributeSet.Add(new LdapAttribute("objectClass", "inetOrgPerson"));
|
[
|
||||||
attributeSet.Add(new LdapAttribute("cn", cn));
|
new LdapAttribute("objectClass", "inetOrgPerson"),
|
||||||
attributeSet.Add(new LdapAttribute("sn", sn));
|
new LdapAttribute("cn", cn),
|
||||||
attributeSet.Add(new LdapAttribute("title", title));
|
new LdapAttribute("sn", sn),
|
||||||
attributeSet.Add(new LdapAttribute("uid", uid));
|
new LdapAttribute("title", title),
|
||||||
attributeSet.Add(new LdapAttribute("jpegPhoto", jpegPhoto));
|
new LdapAttribute("uid", uid),
|
||||||
attributeSet.Add(new LdapAttribute("description", description));
|
new LdapAttribute("jpegPhoto", jpegPhoto),
|
||||||
attributeSet.Add(new LdapAttribute("userPassword", userPassword));
|
new LdapAttribute("description", description),
|
||||||
|
new LdapAttribute("userPassword", userPassword),
|
||||||
|
];
|
||||||
await _ldap.CreateUser(uid, attributeSet);
|
await _ldap.CreateUser(uid, attributeSet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user