Skip to content

Commit

Permalink
Add POSIX gidNumber for IPA groups in Global Catalog
Browse files Browse the repository at this point in the history
Since groups in FreeIPA may be non-POSIX, only add gidNumber and the
corresponding object class if the group is POSIX one.

Define common macros in a separate template.

Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
  • Loading branch information
abbra committed Aug 14, 2023
1 parent 2c9a2e6 commit 97e859e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
14 changes: 14 additions & 0 deletions ipaserver/globalcatalog/templates/gc_base.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% macro add_objectclass(attr, objectclass, entry, ns) -%}
{%- if attr in entry -%}
{%- if not (objectclass in ns.objectclasses) -%}
{%- set ns.objectclasses = ns.objectclasses + [objectclass] -%}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{%- macro print_attr(attr, entry) %}
{%- if attr in entry -%}
{%- for el in entry[attr] %}
{{ attr }}: {{- el -}}
{% endfor -%}
{% endif -%}
{% endmacro -%}
27 changes: 12 additions & 15 deletions ipaserver/globalcatalog/templates/gc_group_template.tmpl
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
{%- set ns = namespace(objectclasses=['top', 'ad-top', 'group', 'securityprincipal', 'nsmemberof', 'gcobject']) -%}
{%- import "gc_base.tmpl" as base -%}
{{- base.add_objectclass('gidnumber', 'posixgroup', entry, ns) -}}
dn: cn={{ pkey }},cn=users,{{ suffix }}
objectClass: top
objectClass: ad-top
objectClass: group
objectClass: securityprincipal
objectClass: nsmemberof
objectClass: gcobject
cn: {{ pkey }}
{%- for el in ns.objectclasses %}
objectclass: {{ el }}
{%- endfor %}
instanceType: 4
groupType: {{ groupType }}
gcuuid: {{ entryuuid }}
name: {{ pkey }}
objectGUID:: {{ guid }}
objectSid:: {{ sid }}
sAMAccountName: {{ pkey }}
sAMAccountName: {{ pkey }}
sAMAccountType: 268435456
objectCategory: CN=Group,CN=Schema,CN=Configuration,{{ suffix }}
ntsecuritydescriptor: D:(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;DA)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)(A;;RPLCLORC;;;AU)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;AO)(A;;RPLCLORC;;;PS)(OA;;CR;ab721a55-1e2f-11d0-9819-00aa0040529b;;AU)
{%- for member in entry['member'] %}
member: {{ member }}
{%- endfor %}
{%- for group in entry['memberof'] %}
memberof: {{ group }}
{%- endfor %}
groupType: {{ groupType }}
gcuuid: {{ entryuuid }}
{{- base.print_attr('member', entry) -}}
{{- base.print_attr('memberof', entry) -}}
{{- base.print_attr('gidnumber', entry) -}}

0 comments on commit 97e859e

Please sign in to comment.