AnsweredAssumed Answered

behaviour context problem

Question asked by scouil on May 11, 2012
Latest reply on May 11, 2012 by scouil
Hello everyone,

I'm trying to get a control over the users added to alfresco.
When a user is added to alfresco, I want to check the domain of the email adress and if it's one of ours, automatically enable the user account and add him to the appropriate group depending on this domain.

In order to do so, I added a custom behavior onCreateNode for cm:person.
Since I already have quite a lot of webscripts written in javascript running on top of Alfresco with externalized constants and so on, I chose to write that custom behaviour in javascript too.

When the user is created with the site "external invitation" feature, it works.
When the user is created from share user interface (http://localhost:8080/share/page/console/admin-console/users#state=panel%3Dcreate) it works.
When the user is created via the script console (http://code.google.com/p/share-extras/wiki/JavascriptConsole) it works.

However, for the users whose account is created on ldap login (haven't tested with ldap synchronization), the script is started in an unusual way (not by a user).
This cause
behaviour.args[0].getChild()
to evaluate to "A valid SecureContext was not provided in the RequestContext" instead of the user node.

I'll create a Jira since this is clearly a bug. The script should probably be called by the "System" user.
However, I was thinking that maybe I could force the behavior to execute with specific user rights (like the runas="admin" for the webscripts) for the time being. How can I add such a property to my spring bean?

TLDR: Can a custom behavior be forced to execute as if started by the admin or system user?

Outcomes