diff --git a/src/Services/LdapService.cs b/src/Services/LdapService.cs index 1e6c101..46ed2f2 100644 --- a/src/Services/LdapService.cs +++ b/src/Services/LdapService.cs @@ -196,9 +196,15 @@ public async Task CreateAsset(LdapAttributeSet attributeSet) } public async Task CreateLocation(LdapAttributeSet attributeSet) - { - await CreateObject(LocationsBaseDn, attributeSet); - } +{ + string? cn = attributeSet.GetAttribute("cn")?.StringValue; + + if (string.IsNullOrEmpty(cn)) + throw new ArgumentException("AttributeSet must contain a cn attribute."); + + string dn = PrependRDN($"cn={cn}", LocationsBaseDn); + await CreateObject(dn, attributeSet); +} public async Task AuthenticateUser(string username, string password) {