Friday, September 16, 2011

Solved password reset for UCM 11g

Today I returned to the password reset issue in UCM 11g, and I solved it by creating a custom component. Just less than 27 line of code solved it !!! till now I wonder why Oracle missed that.

Anyway I want to share it with you in case you faced the same problem and you were looking for a solution.

I will assume you know how to create a custom service, and in case if you don't know refer to The Definitive Guide to Stellent Oracle Content Server for Bex Huff.

1- Create a custom component using Component Wizard

2- Create a java class and make this class extends UserService

3- Add the following method to the class


public void resetPassword() throws Exception {
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.PROVIDER_URL, "ldap://localhost:7001/dc=my_domain");
      env.put(Context.SECURITY_AUTHENTICATION, "simple");
      env.put(Context.SECURITY_PRINCIPAL, "cn=Admin");
      env.put(Context.SECURITY_CREDENTIALS, "weblogic1");
      DirContext ctx = new InitialDirContext(env);
      ModificationItem[] mods = new ModificationItem[1];
      Attribute mod0 = new BasicAttribute("userpassword", m_binder.getLocal("dPassword"));
      mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);
      ctx.modifyAttributes("uid=sysadmin,ou=people,ou=myrealm", mods);
}

3- Modify the existing service EDIT_USER_PROFILE (by the Component Wizard)
-Change service class to the newly created class by you (don't forget package name)
-Then add new action which is of type java method and refers to our newly created method resetPassword
-Order actions so that resetPassword be before storeUserDatabaseProfileData

At the end restart and test. One last thing from inside weblogic administration console, you need to change embedded ldap credential and be sure it is configured correctly.

5 comments:

Tomislav said...

Hi,

did you faced any problems when doing this. I need this feature in my project, and don't know if this is ok without any bugs.

Thanx

Hisham Galal said...

No, but I have some tips:

- weblogic should be started before ucm
- you should set password for embedded ldap admin
- test your code using java main method before adding it to the server

if still there is a problem, send to me the stack trace to help you

Tomislav said...

Hi my error is in credentials

Code:
public class CustomPasswordChange extends UserService{

public CustomPasswordChange(){}

public void resetPassword() throws Exception {

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

//env.put(Context.PROVIDER_URL, "ldap://localhost:7001/dc=my_domain");
env.put(Context.PROVIDER_URL, "ldap://s-dms-2k8:7001/dc=ecm_domain");

env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=Admin");
//env.put(Context.SECURITY_PRINCIPAL, "cn=weblogic");

env.put(Context.SECURITY_CREDENTIALS, "weblogic");


DirContext ctx = new InitialDirContext(env);

ModificationItem[] mods = new ModificationItem[1];
Attribute mod0 = new BasicAttribute("userpassword", m_binder.getLocal("dPassword"));
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);
ctx.modifyAttributes("uid=sysadmin,ou=people,ou=myrealm", mods);
}

}


Error on line DirContext ctx = new InitialDirContext(env):

Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]

Anonymous said...

How to filter .dll ,.exe files while check-in using custom component.

Hisham Galal said...

Explain for me more about filtering requirements.

Regarding the lost password, send me your email and I will send to you the component.