cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable user programmatically

gommo
Champ in-the-making
Champ in-the-making
I'm creating users via a custom UserRegistry returning NodeDescription with properties.
e.g.
PropertyMap properties = node.getProperties();

properties.put(ContentModel.PROP_USERNAME, user.getName());
properties.put(ContentModel.PROP_FIRSTNAME, user.getFirstName());
properties.put(ContentModel.PROP_LASTNAME, user.getLastName());
properties.put(ContentModel.PROP_EMAIL, user.getEmailAddress());

However, it appears some users are coming up as disabled, particularly when viewed via share.

What property or service methods are available to set the user to enabled.
I tried these two, PROP_ENABLED & PROP_MODEL_ACTIVE

But they didn't seem to affect share.

Thanks
2 REPLIES 2

mitpatoliya
Star Collaborator
Star Collaborator
Yes, once you create the user you need to create authentication for that user which will enable the user in repo.

gommo
Champ in-the-making
Champ in-the-making
I'm not sure I totally follow. The user exists in the repo. I just don't seem to be able to control the enable/disable flag.

e.g.

authenticationService.setAuthenticationEnabled(user.getName(), false);

logger.debug(" Is this user mutable? " + authenticationService.isAuthenticationMutable(user.getName()) + " ,enabled? " + authenticationService.getAuthenticationEnabled(user.getName()));
logger.debug(" Is person enabled? " + personService.isEnabled(user.getName()));

The above outputs that the user is mutable and enabled even though the first line specifically disables the user.

SO I'm at a loss as to how to properly control the enable/disable of a user account.
Similar I guess to this thread which doesn't have a resolution either - http://forums.alfresco.com/forum/installation-upgrades-configuration-integration/authentication-ldap...