Forum

Accueil » Liferay Portal » English » x. Miscellaneous

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
quentin giraudon
Manually create users with SQL
19 septembre 2012 08:43
Réponse

quentin giraudon

Rang: New Member

Publications: 11

Date d'inscription: 19 septembre 2012

Publications Récentes

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
David H Nebinger
RE: Manually create users with SQL
19 septembre 2012 09:47
Réponse

David H Nebinger

Rang: Liferay Legend

Publications: 7238

Date d'inscription: 1 septembre 2006

Publications Récentes

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
RE: Manually create users with SQL
19 septembre 2012 14:05
Réponse

quentin giraudon

Rang: New Member

Publications: 11

Date d'inscription: 19 septembre 2012

Publications Récentes

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 ?
David H Nebinger
RE: Manually create users with SQL
19 septembre 2012 14:17
Réponse

David H Nebinger

Rang: Liferay Legend

Publications: 7238

Date d'inscription: 1 septembre 2006

Publications Récentes

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
RE: Manually create users with SQL
20 septembre 2012 08:26
Réponse

quentin giraudon

Rang: New Member

Publications: 11

Date d'inscription: 19 septembre 2012

Publications Récentes

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.
David H Nebinger
RE: Manually create users with SQL
23 septembre 2012 14:08
Réponse

David H Nebinger

Rang: Liferay Legend

Publications: 7238

Date d'inscription: 1 septembre 2006

Publications Récentes

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.