1. Packages
  2. Keycloak Provider
  3. API Docs
  4. ldap
  5. FullNameMapper
Keycloak v6.3.0 published on Tuesday, Apr 15, 2025 by Pulumi

keycloak.ldap.FullNameMapper

Explore with Pulumi AI

Allows for creating and managing full name mappers for Keycloak users federated via LDAP.

The LDAP full name mapper can map a user’s full name from an LDAP attribute to the first and last name attributes of a Keycloak user.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    realm: "my-realm",
    enabled: true,
});
const ldapUserFederation = new keycloak.ldap.UserFederation("ldap_user_federation", {
    name: "openldap",
    realmId: realm.id,
    usernameLdapAttribute: "cn",
    rdnLdapAttribute: "cn",
    uuidLdapAttribute: "entryDN",
    userObjectClasses: [
        "simpleSecurityObject",
        "organizationalRole",
    ],
    connectionUrl: "ldap://openldap",
    usersDn: "dc=example,dc=org",
    bindDn: "cn=admin,dc=example,dc=org",
    bindCredential: "admin",
});
const ldapFullNameMapper = new keycloak.ldap.FullNameMapper("ldap_full_name_mapper", {
    realmId: realm.id,
    ldapUserFederationId: ldapUserFederation.id,
    name: "full-name-mapper",
    ldapFullNameAttribute: "cn",
});
Copy
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
ldap_user_federation = keycloak.ldap.UserFederation("ldap_user_federation",
    name="openldap",
    realm_id=realm.id,
    username_ldap_attribute="cn",
    rdn_ldap_attribute="cn",
    uuid_ldap_attribute="entryDN",
    user_object_classes=[
        "simpleSecurityObject",
        "organizationalRole",
    ],
    connection_url="ldap://openldap",
    users_dn="dc=example,dc=org",
    bind_dn="cn=admin,dc=example,dc=org",
    bind_credential="admin")
ldap_full_name_mapper = keycloak.ldap.FullNameMapper("ldap_full_name_mapper",
    realm_id=realm.id,
    ldap_user_federation_id=ldap_user_federation.id,
    name="full-name-mapper",
    ldap_full_name_attribute="cn")
Copy
package main

import (
	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak/ldap"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		realm, err := keycloak.NewRealm(ctx, "realm", &keycloak.RealmArgs{
			Realm:   pulumi.String("my-realm"),
			Enabled: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		ldapUserFederation, err := ldap.NewUserFederation(ctx, "ldap_user_federation", &ldap.UserFederationArgs{
			Name:                  pulumi.String("openldap"),
			RealmId:               realm.ID(),
			UsernameLdapAttribute: pulumi.String("cn"),
			RdnLdapAttribute:      pulumi.String("cn"),
			UuidLdapAttribute:     pulumi.String("entryDN"),
			UserObjectClasses: pulumi.StringArray{
				pulumi.String("simpleSecurityObject"),
				pulumi.String("organizationalRole"),
			},
			ConnectionUrl:  pulumi.String("ldap://openldap"),
			UsersDn:        pulumi.String("dc=example,dc=org"),
			BindDn:         pulumi.String("cn=admin,dc=example,dc=org"),
			BindCredential: pulumi.String("admin"),
		})
		if err != nil {
			return err
		}
		_, err = ldap.NewFullNameMapper(ctx, "ldap_full_name_mapper", &ldap.FullNameMapperArgs{
			RealmId:               realm.ID(),
			LdapUserFederationId:  ldapUserFederation.ID(),
			Name:                  pulumi.String("full-name-mapper"),
			LdapFullNameAttribute: pulumi.String("cn"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Keycloak = Pulumi.Keycloak;

return await Deployment.RunAsync(() => 
{
    var realm = new Keycloak.Realm("realm", new()
    {
        RealmName = "my-realm",
        Enabled = true,
    });

    var ldapUserFederation = new Keycloak.Ldap.UserFederation("ldap_user_federation", new()
    {
        Name = "openldap",
        RealmId = realm.Id,
        UsernameLdapAttribute = "cn",
        RdnLdapAttribute = "cn",
        UuidLdapAttribute = "entryDN",
        UserObjectClasses = new[]
        {
            "simpleSecurityObject",
            "organizationalRole",
        },
        ConnectionUrl = "ldap://openldap",
        UsersDn = "dc=example,dc=org",
        BindDn = "cn=admin,dc=example,dc=org",
        BindCredential = "admin",
    });

    var ldapFullNameMapper = new Keycloak.Ldap.FullNameMapper("ldap_full_name_mapper", new()
    {
        RealmId = realm.Id,
        LdapUserFederationId = ldapUserFederation.Id,
        Name = "full-name-mapper",
        LdapFullNameAttribute = "cn",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.keycloak.Realm;
import com.pulumi.keycloak.RealmArgs;
import com.pulumi.keycloak.ldap.UserFederation;
import com.pulumi.keycloak.ldap.UserFederationArgs;
import com.pulumi.keycloak.ldap.FullNameMapper;
import com.pulumi.keycloak.ldap.FullNameMapperArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var realm = new Realm("realm", RealmArgs.builder()
            .realm("my-realm")
            .enabled(true)
            .build());

        var ldapUserFederation = new UserFederation("ldapUserFederation", UserFederationArgs.builder()
            .name("openldap")
            .realmId(realm.id())
            .usernameLdapAttribute("cn")
            .rdnLdapAttribute("cn")
            .uuidLdapAttribute("entryDN")
            .userObjectClasses(            
                "simpleSecurityObject",
                "organizationalRole")
            .connectionUrl("ldap://openldap")
            .usersDn("dc=example,dc=org")
            .bindDn("cn=admin,dc=example,dc=org")
            .bindCredential("admin")
            .build());

        var ldapFullNameMapper = new FullNameMapper("ldapFullNameMapper", FullNameMapperArgs.builder()
            .realmId(realm.id())
            .ldapUserFederationId(ldapUserFederation.id())
            .name("full-name-mapper")
            .ldapFullNameAttribute("cn")
            .build());

    }
}
Copy
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  ldapUserFederation:
    type: keycloak:ldap:UserFederation
    name: ldap_user_federation
    properties:
      name: openldap
      realmId: ${realm.id}
      usernameLdapAttribute: cn
      rdnLdapAttribute: cn
      uuidLdapAttribute: entryDN
      userObjectClasses:
        - simpleSecurityObject
        - organizationalRole
      connectionUrl: ldap://openldap
      usersDn: dc=example,dc=org
      bindDn: cn=admin,dc=example,dc=org
      bindCredential: admin
  ldapFullNameMapper:
    type: keycloak:ldap:FullNameMapper
    name: ldap_full_name_mapper
    properties:
      realmId: ${realm.id}
      ldapUserFederationId: ${ldapUserFederation.id}
      name: full-name-mapper
      ldapFullNameAttribute: cn
Copy

Create FullNameMapper Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new FullNameMapper(name: string, args: FullNameMapperArgs, opts?: CustomResourceOptions);
@overload
def FullNameMapper(resource_name: str,
                   args: FullNameMapperArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def FullNameMapper(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   ldap_full_name_attribute: Optional[str] = None,
                   ldap_user_federation_id: Optional[str] = None,
                   realm_id: Optional[str] = None,
                   name: Optional[str] = None,
                   read_only: Optional[bool] = None,
                   write_only: Optional[bool] = None)
func NewFullNameMapper(ctx *Context, name string, args FullNameMapperArgs, opts ...ResourceOption) (*FullNameMapper, error)
public FullNameMapper(string name, FullNameMapperArgs args, CustomResourceOptions? opts = null)
public FullNameMapper(String name, FullNameMapperArgs args)
public FullNameMapper(String name, FullNameMapperArgs args, CustomResourceOptions options)
type: keycloak:ldap:FullNameMapper
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. FullNameMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. FullNameMapperArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. FullNameMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. FullNameMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. FullNameMapperArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var fullNameMapperResource = new Keycloak.Ldap.FullNameMapper("fullNameMapperResource", new()
{
    LdapFullNameAttribute = "string",
    LdapUserFederationId = "string",
    RealmId = "string",
    Name = "string",
    ReadOnly = false,
    WriteOnly = false,
});
Copy
example, err := ldap.NewFullNameMapper(ctx, "fullNameMapperResource", &ldap.FullNameMapperArgs{
	LdapFullNameAttribute: pulumi.String("string"),
	LdapUserFederationId:  pulumi.String("string"),
	RealmId:               pulumi.String("string"),
	Name:                  pulumi.String("string"),
	ReadOnly:              pulumi.Bool(false),
	WriteOnly:             pulumi.Bool(false),
})
Copy
var fullNameMapperResource = new FullNameMapper("fullNameMapperResource", FullNameMapperArgs.builder()
    .ldapFullNameAttribute("string")
    .ldapUserFederationId("string")
    .realmId("string")
    .name("string")
    .readOnly(false)
    .writeOnly(false)
    .build());
Copy
full_name_mapper_resource = keycloak.ldap.FullNameMapper("fullNameMapperResource",
    ldap_full_name_attribute="string",
    ldap_user_federation_id="string",
    realm_id="string",
    name="string",
    read_only=False,
    write_only=False)
Copy
const fullNameMapperResource = new keycloak.ldap.FullNameMapper("fullNameMapperResource", {
    ldapFullNameAttribute: "string",
    ldapUserFederationId: "string",
    realmId: "string",
    name: "string",
    readOnly: false,
    writeOnly: false,
});
Copy
type: keycloak:ldap:FullNameMapper
properties:
    ldapFullNameAttribute: string
    ldapUserFederationId: string
    name: string
    readOnly: false
    realmId: string
    writeOnly: false
Copy

FullNameMapper Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The FullNameMapper resource accepts the following input properties:

LdapFullNameAttribute This property is required. string
The name of the LDAP attribute containing the user's full name.
LdapUserFederationId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the LDAP user federation provider to attach this mapper to.
RealmId
This property is required.
Changes to this property will trigger replacement.
string
The realm that this LDAP mapper will exist in.
Name string
Display name of this mapper when displayed in the console.
ReadOnly bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
WriteOnly bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
LdapFullNameAttribute This property is required. string
The name of the LDAP attribute containing the user's full name.
LdapUserFederationId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the LDAP user federation provider to attach this mapper to.
RealmId
This property is required.
Changes to this property will trigger replacement.
string
The realm that this LDAP mapper will exist in.
Name string
Display name of this mapper when displayed in the console.
ReadOnly bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
WriteOnly bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute This property is required. String
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the LDAP user federation provider to attach this mapper to.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The realm that this LDAP mapper will exist in.
name String
Display name of this mapper when displayed in the console.
readOnly Boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
writeOnly Boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute This property is required. string
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the LDAP user federation provider to attach this mapper to.
realmId
This property is required.
Changes to this property will trigger replacement.
string
The realm that this LDAP mapper will exist in.
name string
Display name of this mapper when displayed in the console.
readOnly boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
writeOnly boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldap_full_name_attribute This property is required. str
The name of the LDAP attribute containing the user's full name.
ldap_user_federation_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the LDAP user federation provider to attach this mapper to.
realm_id
This property is required.
Changes to this property will trigger replacement.
str
The realm that this LDAP mapper will exist in.
name str
Display name of this mapper when displayed in the console.
read_only bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
write_only bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute This property is required. String
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the LDAP user federation provider to attach this mapper to.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The realm that this LDAP mapper will exist in.
name String
Display name of this mapper when displayed in the console.
readOnly Boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
writeOnly Boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.

Outputs

All input properties are implicitly available as output properties. Additionally, the FullNameMapper resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing FullNameMapper Resource

Get an existing FullNameMapper resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FullNameMapperState, opts?: CustomResourceOptions): FullNameMapper
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        ldap_full_name_attribute: Optional[str] = None,
        ldap_user_federation_id: Optional[str] = None,
        name: Optional[str] = None,
        read_only: Optional[bool] = None,
        realm_id: Optional[str] = None,
        write_only: Optional[bool] = None) -> FullNameMapper
func GetFullNameMapper(ctx *Context, name string, id IDInput, state *FullNameMapperState, opts ...ResourceOption) (*FullNameMapper, error)
public static FullNameMapper Get(string name, Input<string> id, FullNameMapperState? state, CustomResourceOptions? opts = null)
public static FullNameMapper get(String name, Output<String> id, FullNameMapperState state, CustomResourceOptions options)
resources:  _:    type: keycloak:ldap:FullNameMapper    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
LdapFullNameAttribute string
The name of the LDAP attribute containing the user's full name.
LdapUserFederationId Changes to this property will trigger replacement. string
The ID of the LDAP user federation provider to attach this mapper to.
Name string
Display name of this mapper when displayed in the console.
ReadOnly bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
RealmId Changes to this property will trigger replacement. string
The realm that this LDAP mapper will exist in.
WriteOnly bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
LdapFullNameAttribute string
The name of the LDAP attribute containing the user's full name.
LdapUserFederationId Changes to this property will trigger replacement. string
The ID of the LDAP user federation provider to attach this mapper to.
Name string
Display name of this mapper when displayed in the console.
ReadOnly bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
RealmId Changes to this property will trigger replacement. string
The realm that this LDAP mapper will exist in.
WriteOnly bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute String
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId Changes to this property will trigger replacement. String
The ID of the LDAP user federation provider to attach this mapper to.
name String
Display name of this mapper when displayed in the console.
readOnly Boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
realmId Changes to this property will trigger replacement. String
The realm that this LDAP mapper will exist in.
writeOnly Boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute string
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId Changes to this property will trigger replacement. string
The ID of the LDAP user federation provider to attach this mapper to.
name string
Display name of this mapper when displayed in the console.
readOnly boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
realmId Changes to this property will trigger replacement. string
The realm that this LDAP mapper will exist in.
writeOnly boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldap_full_name_attribute str
The name of the LDAP attribute containing the user's full name.
ldap_user_federation_id Changes to this property will trigger replacement. str
The ID of the LDAP user federation provider to attach this mapper to.
name str
Display name of this mapper when displayed in the console.
read_only bool
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
realm_id Changes to this property will trigger replacement. str
The realm that this LDAP mapper will exist in.
write_only bool
When true, this mapper will only be used to write updates to LDAP. Defaults to false.
ldapFullNameAttribute String
The name of the LDAP attribute containing the user's full name.
ldapUserFederationId Changes to this property will trigger replacement. String
The ID of the LDAP user federation provider to attach this mapper to.
name String
Display name of this mapper when displayed in the console.
readOnly Boolean
When true, updates to a user within Keycloak will not be written back to LDAP. Defaults to false.
realmId Changes to this property will trigger replacement. String
The realm that this LDAP mapper will exist in.
writeOnly Boolean
When true, this mapper will only be used to write updates to LDAP. Defaults to false.

Import

LDAP mappers can be imported using the format {{realm_id}}/{{ldap_user_federation_id}}/{{ldap_mapper_id}}.

The ID of the LDAP user federation provider and the mapper can be found within the Keycloak GUI, and they are typically GUIDs.

Example:

bash

$ pulumi import keycloak:ldap/fullNameMapper:FullNameMapper ldap_full_name_mapper my-realm/af2a6ca3-e4d7-49c3-b08b-1b3c70b4b860/3d923ece-1a91-4bf7-adaf-3b82f2a12b67
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Keycloak pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.