]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Ensure LDAP group attribute exists
authorNick Porter <nick@portercomputing.co.uk>
Fri, 28 Apr 2023 13:15:59 +0000 (14:15 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 19 May 2023 19:35:55 +0000 (15:35 -0400)
src/modules/rlm_ldap/rlm_ldap.c

index edc80b0c3b3a6ce845366078f5f7c2ff35c512f8..8a33e7097c0f3366804e848645985e5fa9b141e1 100644 (file)
@@ -1851,6 +1851,22 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
 
        inst->group_da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_freeradius), group_attribute);
 
+       /*
+        *      If the group attribute was not in the dictionary, create it
+        */
+       if (!inst->group_da) {
+               fr_dict_attr_flags_t    flags;
+
+               memset(&flags, 0, sizeof(flags));
+               if (fr_dict_attr_add(fr_dict_unconst(dict_freeradius), fr_dict_root(dict_freeradius),
+                                    group_attribute, -1, FR_TYPE_STRING, &flags) < 0) {
+                       PERROR("Error creating group attribute");
+                       return -1;
+
+               }
+               inst->group_da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_freeradius), group_attribute);
+       }
+
        /*
         *      Setup the cache attribute
         */