MCPcopy Create free account
hub / github.com/USBGuard/usbguard / query

Method query

src/Daemon/LDAPHandler.cpp:114–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 }
113
114 std::shared_ptr<LDAPMessage> LDAPHandler::query(const std::string filter)
115 {
116 USBGUARD_LOG(Debug) << "Trying to fetch LDAP data, query: " << filter;
117 LDAPMessage* res = nullptr;
118 int rc = ldap_search_ext_s(_ldap_ptr.get(), _parsedOptions["USBGUARDBASE"].c_str(),
119 LDAP_SCOPE_SUBTREE, filter.c_str(), nullptr, false,
120 nullptr, nullptr, nullptr, 0, &res);
121
122 if (rc != LDAP_SUCCESS) {
123 ldap_msgfree(res);
124 throw Exception("LDAPHandler query", "ldap_search_ext_s", ldap_err2string(rc));
125 }
126
127 std::shared_ptr<LDAPMessage> ptr(res, LDAPHandler::LDAPDeleter());
128 USBGUARD_LOG(Debug) << "Fetched LDAP DNs: ";
129 char* dn = nullptr;
130
131 for ( LDAPMessage* e = ldap_first_entry( _ldap_ptr.get(), ptr.get() ); e != nullptr;
132 e = ldap_next_entry( _ldap_ptr.get(), e ) ) {
133 if ((dn = ldap_get_dn( _ldap_ptr.get(), e )) != NULL ) {
134 USBGUARD_LOG(Debug) << "dn: " << dn;
135 ldap_memfree( dn );
136 }
137 }
138
139 return ptr;
140 }
141
142 std::vector<std::pair<long, std::string>> LDAPHandler::ldapToRules(std::shared_ptr<LDAPMessage> message)
143 {

Callers 2

loadMethod · 0.80
handleListDevicesMethod · 0.80

Calls 2

ExceptionFunction · 0.85
LDAPDeleterClass · 0.85

Tested by

no test coverage detected