掲示板

Manually create users with SQL

11年前 に quentin giraudon によって更新されました。

Manually create users with SQL

New Member 投稿: 11 参加年月日: 12/09/19 最新の投稿
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
11年前 に David H Nebinger によって更新されました。

RE: Manually create users with SQL

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
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.
11年前 に quentin giraudon によって更新されました。

RE: Manually create users with SQL

New Member 投稿: 11 参加年月日: 12/09/19 最新の投稿
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
11年前 に David H Nebinger によって更新されました。

RE: Manually create users with SQL

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
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.
11年前 に quentin giraudon によって更新されました。

RE: Manually create users with SQL

New Member 投稿: 11 参加年月日: 12/09/19 最新の投稿
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
11年前 に David H Nebinger によって更新されました。

RE: Manually create users with SQL

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
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.
8年前 に min liu によって更新されました。

RE: Manually create users with SQL

New Member 投稿: 5 参加年月日: 15/08/26 最新の投稿
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.