securely getting orphan users LDAP



Hi guys,

I found the following example on how to programmatically get the orphan users from my LDAP server:

How to Synchronize User with LDAP

My only concern with this code is that it hardcodes the admin user credentials.

I thought about getting the admin password stored in AEM but passwords in AEM are encrypted so this would not work.

I think that when I make this call from the web JMX console, the post request is using the login-token from the cookie and so it does not need the admin user credentials.

Is there a way to use the login-token from the java code?

Or is there any other way to get the orphan users that does not involve hardcoding admin user credentials?

Thanks in advance,