| 78 | } |
| 79 | |
| 80 | Status LdapSimpleBind::Init(const string& user_filter, const string& group_filter) { |
| 81 | RETURN_IF_ERROR(ImpalaLdap::Init(user_filter, group_filter)); |
| 82 | |
| 83 | if (!user_filter.empty()) { |
| 84 | user_filter_ = Split(user_filter, ","); |
| 85 | } |
| 86 | if (!group_filter.empty()) { |
| 87 | if (FLAGS_ldap_group_dn_pattern.empty()) { |
| 88 | return Status("In order to apply an LDAP group filter, --ldap_group_dn_pattern " |
| 89 | "must be specified."); |
| 90 | } |
| 91 | group_filter_ = Split(group_filter, ","); |
| 92 | vector<string> group_dns = Split(FLAGS_ldap_group_dn_pattern, ":"); |
| 93 | |
| 94 | // Build the list of DNs to search for groups by iterating through the |
| 95 | // DN patterns and replacing the optional '%s' with each group name, if present. |
| 96 | for (const string& group_dn_pattern : group_dns) { |
| 97 | if (group_dn_pattern.find("%s") != string::npos) { |
| 98 | for (const string& group : group_filter_) { |
| 99 | group_base_dns_.push_back( |
| 100 | StringReplace(group_dn_pattern, "%s", group, /* replace_all */ false)); |
| 101 | } |
| 102 | } else { |
| 103 | group_base_dns_.push_back(group_dn_pattern); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | return Status::OK(); |
| 109 | } |
| 110 | |
| 111 | bool LdapSimpleBind::LdapCheckPass(const char* user, const char* pass, unsigned passlen) { |
| 112 | string user_dn = ConstructUserDN(user); |