UserAttributeMapperArgs

data class UserAttributeMapperArgs(val alwaysReadValueFromLdap: Output<Boolean>? = null, val attributeDefaultValue: Output<String>? = null, val attributeForceDefault: Output<Boolean>? = null, val isBinaryAttribute: Output<Boolean>? = null, val isMandatoryInLdap: Output<Boolean>? = null, val ldapAttribute: Output<String>? = null, val ldapUserFederationId: Output<String>? = null, val name: Output<String>? = null, val readOnly: Output<Boolean>? = null, val realmId: Output<String>? = null, val userModelAttribute: Output<String>? = null) : ConvertibleToJava<UserAttributeMapperArgs>

Allows for creating and managing user attribute mappers for Keycloak users federated via LDAP. The LDAP user attribute mapper can be used to map a single LDAP attribute to an attribute on the Keycloak user model.

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 ldapUserAttributeMapper = new keycloak.ldap.UserAttributeMapper("ldap_user_attribute_mapper", {
realmId: realm.id,
ldapUserFederationId: ldapUserFederation.id,
name: "user-attribute-mapper",
userModelAttribute: "foo",
ldapAttribute: "bar",
});
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_user_attribute_mapper = keycloak.ldap.UserAttributeMapper("ldap_user_attribute_mapper",
realm_id=realm.id,
ldap_user_federation_id=ldap_user_federation.id,
name="user-attribute-mapper",
user_model_attribute="foo",
ldap_attribute="bar")
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 ldapUserAttributeMapper = new Keycloak.Ldap.UserAttributeMapper("ldap_user_attribute_mapper", new()
{
RealmId = realm.Id,
LdapUserFederationId = ldapUserFederation.Id,
Name = "user-attribute-mapper",
UserModelAttribute = "foo",
LdapAttribute = "bar",
});
});
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.NewUserAttributeMapper(ctx, "ldap_user_attribute_mapper", &ldap.UserAttributeMapperArgs{
RealmId: realm.ID(),
LdapUserFederationId: ldapUserFederation.ID(),
Name: pulumi.String("user-attribute-mapper"),
UserModelAttribute: pulumi.String("foo"),
LdapAttribute: pulumi.String("bar"),
})
if err != nil {
return err
}
return nil
})
}
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.UserAttributeMapper;
import com.pulumi.keycloak.ldap.UserAttributeMapperArgs;
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 ldapUserAttributeMapper = new UserAttributeMapper("ldapUserAttributeMapper", UserAttributeMapperArgs.builder()
.realmId(realm.id())
.ldapUserFederationId(ldapUserFederation.id())
.name("user-attribute-mapper")
.userModelAttribute("foo")
.ldapAttribute("bar")
.build());
}
}
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
ldapUserAttributeMapper:
type: keycloak:ldap:UserAttributeMapper
name: ldap_user_attribute_mapper
properties:
realmId: ${realm.id}
ldapUserFederationId: ${ldapUserFederation.id}
name: user-attribute-mapper
userModelAttribute: foo
ldapAttribute: bar

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/userAttributeMapper:UserAttributeMapper ldap_user_attribute_mapper my-realm/af2a6ca3-e4d7-49c3-b08b-1b3c70b4b860/3d923ece-1a91-4bf7-adaf-3b82f2a12b67

Constructors

Link copied to clipboard
constructor(alwaysReadValueFromLdap: Output<Boolean>? = null, attributeDefaultValue: Output<String>? = null, attributeForceDefault: Output<Boolean>? = null, isBinaryAttribute: Output<Boolean>? = null, isMandatoryInLdap: Output<Boolean>? = null, ldapAttribute: Output<String>? = null, ldapUserFederationId: Output<String>? = null, name: Output<String>? = null, readOnly: Output<Boolean>? = null, realmId: Output<String>? = null, userModelAttribute: Output<String>? = null)

Properties

Link copied to clipboard
val alwaysReadValueFromLdap: Output<Boolean>? = null

When true, the value fetched from LDAP will override the value stored in Keycloak. Defaults to false.

Link copied to clipboard
val attributeDefaultValue: Output<String>? = null

Default value to set in LDAP if is_mandatory_in_ldap is true and the value is empty.

Link copied to clipboard
val attributeForceDefault: Output<Boolean>? = null

When true, an empty default value is forced for mandatory attributes even when a default value is not specified. Defaults to true.

Link copied to clipboard
val isBinaryAttribute: Output<Boolean>? = null

Should be true for binary LDAP attributes.

Link copied to clipboard
val isMandatoryInLdap: Output<Boolean>? = null

When true, this attribute must exist in LDAP. Defaults to false.

Link copied to clipboard
val ldapAttribute: Output<String>? = null

Name of the mapped attribute on the LDAP object.

Link copied to clipboard
val ldapUserFederationId: Output<String>? = null

The ID of the LDAP user federation provider to attach this mapper to.

Link copied to clipboard
val name: Output<String>? = null

Display name of this mapper when displayed in the console.

Link copied to clipboard
val readOnly: Output<Boolean>? = null

When true, this attribute is not saved back to LDAP when the user attribute is updated in Keycloak. Defaults to false.

Link copied to clipboard
val realmId: Output<String>? = null

The realm that this LDAP mapper will exist in.

Link copied to clipboard
val userModelAttribute: Output<String>? = null

Name of the user property or attribute you want to map the LDAP attribute into.

Functions

Link copied to clipboard
open override fun toJava(): UserAttributeMapperArgs