#50819 Issue 50818 - dsconf pwdpolicy get error
Closed 3 years ago by spichugi. Opened 4 years ago by mreynolds.
mreynolds/389-ds-base issue50818  into  master

@@ -35,16 +35,17 @@ 

  def _get_pw_policy(inst, targetdn, log, use_json=None):

      pwp_manager = PwPolicyManager(inst)

      policy_type = _get_policy_type(inst, targetdn)

-     attr_list = pwp_manager.get_attr_list()

+     attr_list = list(pwp_manager.arg_to_attr.values())

      if "global" in policy_type.lower():

          targetdn = 'cn=config'

          attr_list.extend(['passwordIsGlobalPolicy', 'nsslapd-pwpolicy_local'])

-         attrs = inst.config.get_attrs_vals_utf8(attr_list)

+         all_attrs = inst.config.get_attrs_vals_utf8(attr_list)

+         attrs = {k: v for k, v in all_attrs.items() if len(v) > 0}

      else:

          policy = pwp_manager.get_pwpolicy_entry(targetdn)

          targetdn = policy.dn

-         attrs = policy.get_attrs_vals_utf8(attr_list)

- 

+         all_attrs = policy.get_attrs_vals_utf8(attr_list)

+         attrs = {k: v for k, v in all_attrs.items() if len(v) > 0}

      if use_json:

          print(json.dumps({"type": "entry", "pwp_type": policy_type, "dn": ensure_str(targetdn), "attrs": attrs}))

      else:

Description:

When trying to retrieve a global or local policy we now see:

            policyError: 'PwPolicyManager' object has no attribute 'get_attr_list'

Someone removed the function get_attr_list() along the way. Added the same logic back, and improved it to only report attributes that are set.

relates: https://pagure.io/389-ds-base/issue/50818

rebased onto 2a67848

4 years ago

Pull-Request has been merged by mreynolds

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3873

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata