Hey guys, I noticed this thread is a little old, but I had a different issue creating users with code similar to what is posted here. I'm using 4.0d Community edition of Alfresco.
I'm trying to create a user on the fly when a user logs in to the system. Here is a snippet of the code I added to the function authenticateImpl in the class org.alfresco.repo.security.authentication.AuthenticationComponentImpl:
QName userVeto = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "UserVeto");
((TransactionServiceImpl)getTransactionService()).setAllowWrite(true, userVeto);
boolean testW = ((TransactionServiceImpl)getTransactionService()).isReadOnly();
boolean testW2 = ((TransactionServiceImpl)getTransactionService()).getAllowWrite();
((PersonServiceImpl)getPersonService()).setTransactionService((TransactionServiceImpl)getTransactionService());
getPersonService().createPerson(properties);
The var testW is false, testW2 is true as expected. The createPerson function is throwing the error:
org.alfresco.service.transaction.ReadOnlyServerException: 02290094 Access Denied. The system is currently in read-only mode.
Is there something else I need to do to authenticate / enable write access? I added the code to modify the transaction service, but it doesn't appear to have done anything. The error is originating in the function newNode in the class org.alfresco.repo.domain.node.AbstractNodeDAOImpl at line 1066.
Note that I do not have the matching source code for this version of the class, so i can't say what is happening at this line. If someone could tell me what source code revision corresponds to the 4.0d community release, that might help as well.
Mainly, I'm hoping there is some way to perform an authentication / enable writing to the directory.