Fórumok

Manually create users with SQL

quentin giraudon, módosítva 11 év-val korábban

Manually create users with SQL

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.09.19. Legújabb bejegyzések
Hi,

in our project, we need to create users by an external java project. (With SQL queries).
The script seems to work fine, since users are available in the control pannel.

The authentication works with CAS Server. If I create manually a user in the control panel, the user is logged successfully.
If i try to connect with a user created with SQL, I am redirected to liferay login page, with guest account.

Is there specific tables we need to add rows ?

For now, we insert lines in tables :
user_
contact_
group_
users_roles
layoutset
layout
mbthread
mbmessage
assetentry
mbdiscussion
resourcepermission

we also try to add lines only in tables :
user_
contact_
group_
users_roles

same result.

There is no traces in tomcat logs files, so....
Thanks for your help
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Manually create users with SQL

Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
This is a bad thing to do and should be avoided.

The Liferay database is their own and, even though you can connect and look at tables, you only get parts of the actual user creation completed.

In this particular case, the local lucene index that Liferay uses for showing the users is not getting updated, and therefore you don't see the users. The quick fix is to reindex, but it is not an ideal solution as you will need to do this every time the script runs.

The actual way you should implement this is to use the Liferay web service API to create the user accounts. This is the only way to a) ensure the user accounts are created correctly and b) will be (mostly) immune to Liferay updates in the future.
quentin giraudon, módosítva 11 év-val korábban

RE: Manually create users with SQL

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.09.19. Legújabb bejegyzések
Thanks for your reply.

In fact, with SQL queries, after reindex in control panel (that's right), the user is visible in the users section of the control panel and i can modify him, etc. But I can't still login...
But that's true, reindexation is still mandatory even if this solution may work.

So i have to try with webservice. The context is this one : A Java project has to be created (totally independant of liferay) , to produce a jar. This jar file will be used by a sheduler every night. The java project has to connect to a LDAP, get users that must be in liferay, create / update / delete them. We can't connect directly LDAP with liferay, it's a requirement.

My questions are : Do i have to create my own webservice in Liferay ( i mean "re-create" the code that create users). Or just create a webservice in Liferay that call the Liferay API (things like userlocalservice -> addUser, etc..) and call it in my independant java project ?
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Manually create users with SQL

Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
You can use the portal-client.jar file (I think it's available in the source download) to springboard your client development. It should have all of the existing API stuff to invoke the Liferay APIs.

You can use the Liferay API to add users, etc.

The portal-client.jar may have some other dependencies (maybe axis, maybe commons-httpclient, not sure) that would need to be satisfied.

But if you use the API, indexing, etc., will be correctly invoked and should fix up all of the issues you're having.
quentin giraudon, módosítva 11 év-val korábban

RE: Manually create users with SQL

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.09.19. Legújabb bejegyzések
Thanks !

I used the webservices solution, and it works great ! I use the Portal_UserService webservice, already present in Liferay, and it does what i want.
The reindexation is automatically done, and after the creation / updates of users, i can directly log in with CAS server, and the user is logged in in Liferay. emoticon

But I founded a problem and I don't know why it is like that :

We use CAS Server so we have a CAS Filter in the web.xml that redirect guest users to CAS server login page automatically
(we don't want any guest access on any page of our Liferay portal)

BUT :
In guest, i can access the page :
http://127.0.0.1:8093/tunnel-web/axis

that list every webservices ! In this page guest can see WSDL ! Why ? and how can i change that ?

it's strange because if i type any kind of url, i'm redirected to CAS Server, but not this particular page.
thumbnail
David H Nebinger, módosítva 11 év-val korábban

RE: Manually create users with SQL

Liferay Legend Bejegyzések: 14914 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
That's not managed by the ROOT web.xml, so it doesn't have any of the filter stuff.

However, the web services all require a username/password combo, so all you can do is build a client, but it does not expose the API.
min liu, módosítva 8 év-val korábban

RE: Manually create users with SQL

New Member Bejegyzések: 5 Csatlakozás dátuma: 2015.08.26. Legújabb bejegyzések
Hi Giraudon,

I have similar situation to create users .

In a new project, we need to move the existing users to liferay database users. I tried to move the users in laferay tables by using SQL scripts, but some how I cannot see users in control panel screen:
I added the records in the following table for each user, still cannot see it, did I miss any tables?
Could you please advise? Thank you
user_
contact_
group_
users_roles
layoutset
assetentry
resourcepermission

By the way, I tried to use Liferay web service API, it is very slow, it only import about 100 users per hour, this is the reason why I used the SQL script solution.