Add custom LDAP attributes to schema #181

Merged
raucao merged 9 commits from feature/custom_ldap_attributes into master 2024-03-19 14:46:45 +00:00
2 changed files with 7 additions and 2 deletions
Showing only changes of commit 06521d1c34 - Show all commits

View File

@ -34,14 +34,17 @@ class LdapService < ApplicationService
client.delete dn: dn
client.get_operation_result.code
end
def delete_all_users!
delete_all_entries!(objectclass: "person")
end
def delete_all_entries!
def delete_all_entries!(objectclass: "*")
if Rails.env.production?
raise "Mass deletion of entries not allowed in production"
end
filter = Net::LDAP::Filter.eq("objectClass", "*")
filter = Net::LDAP::Filter.eq("objectClass", objectclass)
entries = client.search(base: @suffix, filter: filter, attributes: %w{dn})
entries.sort_by!{ |e| e.dn.length }.reverse!

View File

@ -3,6 +3,8 @@ require 'sidekiq/testing'
ldap = LdapService.new
Sidekiq::Testing.inline! do
ldap.delete_all_users!
CreateAccount.call(account: {
username: "admin", domain: "kosmos.org", email: "admin@example.com",
password: "admin is admin", confirmed: true