Disable Keycloak user from LDAP - ldap

I have synchronization between OpenLDAP and Keycloak via user federation, everything works fine(import from LDAP, authentication, etc).
I need to have a possibility to disable Keycloak user from LDAP. I know that it is possible to disable a user from Keycloak, but is there a way to do the same from LDAP? Maybe add some attribute to LDAP record which will be mapped to Keycloak record and user will be disabled.
My goal is: disable authentication for a particular user using LDAP.

I managed to make it work with fedora 389.
I created an "enabled" attribute as String and created the corresponding mapper in the federation configuration as "user-attribute-ldap-mapper".
Now when I change the "enabled" switch in keycloak the change is propagated to ldap

Related

Keycloak same username in multiple federations

I have two user federations in one realm (different active directories). Because both are completely independent, in occurs that the same username is used.
In Microsoft Applications you can use something like "ad1\ttestuser" and "ad2\ttestuser". Is there a way I can configure Keycloak to choose the user federation on login? A solution would be to add a prefix to the username in the mapper but there is no way to do it.
Is there a way I can configure Keycloak to choose the user federation
on login?
You could create a different realm per user federation that you want your users to be able to explicitly authentication against. Then you configure each user federation in its own realm. Finally,
you configured those realms to do identity brokering against the original realm.
The login page would look something like:
You can have a look a this answer which describes this setup in more detail.

Can Keycloak provide alternative authentication if LDAP is down

Let's say I want to have keycloak synced with the LDAP and use it as the source for authentication. (I've managed to do this already)
But is there a way to let the keycloak be itself the identity provider if, for some reason, the LDAP connection is down?
First you should avoid ldap going down, by setting HA, using HAproxy and keepalived for example, as for Keycloak, you can disable "Sync Registrations" in your keycloak LDAP IDP, and create users using the admin interface, these users are stored in your local database of keycloak, and not on the LDAP so even if its goes down those users can stil get access to Keyclaok.
Refer to https://www.janua.fr/understanding-keycloak-user-federation/ for more details.
I managed to create a custom LDAP Storage Provider to do this.
check How to create a custom UserStorageSPI on Keycloak

How to authentication one website using ldap when user was authenticated on another website using ldap

User is authenticated on website using LDAP. How do I automatically authenticate the same user on another website using LDAP. The two websites are on the same domain but separate websites- they both authenticate against same LDAP store. Is an authentication token somehow passed from one to next? Or the credentials or something..? Sort of new to LDAP auth...
You can not use LDAP to achieve Single Sign On. LDAP is an 'authentication protocol' and a 'data model'.
You either need a proprietary mechanism or some standards based technology like OIDC or SAML.

How to setup multiple way of authentication in Jenkins such as LDAP and Jenkins User database?

Actually the authentication into our Jenkins is done through LDAP.
Some people in my team are not member of the LDAP.
Is there a way to use both LDAP and Jenkins user database?
This is not possible as described. The feature request is JENKINS-15063.
However, it is possible to approximate in a few ways (though the Jenkins user database still won't be usable).
For multiple LDAP realms you can set up a single proxy server that combines the forests.
Using PAM you can define multiple authentication sources and fallbacks in e.g. /etc/pam.d/jenkins
Yes that's possible and requires 2 steps:
Add a userNavigate to Jenkins -> Manage Jenkins -> Configure Global Security.
Under Authorization you need to configure who can do what. You can add LDAP groups and/or users and fine tune what they are allowed to do.
If you enabled Matrix-based or Project/Matrix-based authorization then you have a field to add new users/groups. You can add users that are known to LDAP or not known.
Add Credentials
If you added a user that is not known to LDAP you need to create the credentials in Jenkins (i.e. password).
Navigate to Jenkins -> Credentials -> System -> Global Credentials -> Add Credentials
Then add username and password.

Impersonate user with admin credentials in ApacheDS

I want to implement FORGOT password and I need to set the new password for the user without knowing the original one. Because of that I cannot authenticate to LDAP (ApacheDS) with the user credentials. However, when I change the password using the admin credentials the password policy is not applied.
So, I'm trying to see if I can authenticate as the admin but act as the user. Is there any way to implement this functionality against ApacheDS.
Consider using the Proxied Authorization Control as defined in RFC 4370. I am not an Apache DS expert, but I could find the following control on their site.
The ldap.com site also has an example on how to use this control (Scroll down to the section called The Proxied Authorization Request Controls. The code snippet is using the UnboundID LDAP SDK for Java)
I hope this helps.