SlHelpers
Toggle main menu visibility
Loading...
Searching...
No Matches
LDAP.h
1
// SPDX-License-Identifier: GPL-2.0-only
2
3
#pragma once
4
5
#include <string>
6
#include <string_view>
7
#include <unordered_map>
8
#include <unordered_set>
9
10
#include "../helpers/String.h"
11
12
class
INIReader;
13
14
namespace
SlKernCVS {
15
17
class
LDAPUsers {
18
public
:
20
using
UserSet
= std::unordered_set<std::string,
SlHelpers::String::Hash
,
21
SlHelpers::String::Eq
>;
22
23
LDAPUsers() =
delete
;
30
LDAPUsers
(
const
std::string &dn,
const
std::string &password);
31
33
const
UserSet
&
userSet
() const & {
return
m_userSet; }
34
36
UserSet
userSet
() && {
return
std::move(m_userSet); }
37
39
bool
contains
(
const
std::string &key)
const
noexcept
{
return
m_userSet.contains(key); }
40
private
:
41
using
UserMap = std::unordered_map<std::string, std::string>;
42
43
UserSet
m_userSet;
44
45
static
void
walkSection(UserMap &userMap,
const
INIReader &reader,
46
const
std::string §ion,
bool
lognameIsKey);
47
static
void
addUserMapCond(UserMap &userMap, std::string &&logname, std::string &&email);
48
UserMap getMap();
49
void
buildSet(
const
std::string &dn,
const
std::string &password,
const
UserMap &userMap);
50
51
std::pair<std::string_view, bool>
52
getMappedUser(
const
UserMap &userMap,
const
std::string &user)
const
{
53
auto
it = userMap.find(user);
54
if
(it != userMap.end())
55
return
{ it->second,
true
};
56
return
{ user,
false
};
57
}
58
};
59
60
}
// namespace
SlKernCVS::LDAPUsers::UserSet
std::unordered_set< std::string, SlHelpers::String::Hash, SlHelpers::String::Eq > UserSet
Set of users.
Definition
LDAP.h:20
SlKernCVS::LDAPUsers::userSet
const UserSet & userSet() const &
Get the set of users fetched from LDAP.
Definition
LDAP.h:33
SlKernCVS::LDAPUsers::userSet
UserSet userSet() &&
Get the set of users fetched from LDAP (rvalue).
Definition
LDAP.h:36
SlKernCVS::LDAPUsers::LDAPUsers
LDAPUsers(const std::string &dn, const std::string &password)
Construct a new LDAPUsers object.
SlKernCVS::LDAPUsers::contains
bool contains(const std::string &key) const noexcept
Check if a user is in the set of users fetched from LDAP.
Definition
LDAP.h:39
SlHelpers::String::Eq
Equality test for string and string_view to be used in containers.
Definition
String.h:258
SlHelpers::String::Hash
Hash for string and string_view to be used in hashing containers.
Definition
String.h:231
include
kerncvs
LDAP.h
Generated by
1.17.0