• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to add a user to a particular group in SSO mode?

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys

Firstly, I want to inform that I am not a JAVA guy.

I downloaded Jforum for integrating with one of our existing web applications (of course not in JAVA).

I implemented SSO using a sample code from the internet. But, the new user gets created in the GENERAL group.

Does any of you guys have code / techniques to add a new user to a PARTICULAR group instead on GENERAL group?

Please help me out!
[originally posted on jforum.net by ranga]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default group every new user gets added to is defined by the "defaultUserGroup" configuration parameter. You can a line like the one below to your custom config file (in the WEB-INF/config directory) to use a different group:

defaultUserGroup = 5

The number is the group_id key field of the group in the jforum_groups table. I think it's also part of the URL when you edit a group's permissions as well.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Monroe for the quick respone.

What if I wanted to assign a user to a group based on the role of the user in the existing application? Do I need to write a customized code for it?

Thanks again!
[originally posted on jforum.net by ranga]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume you are trying to link you existing application groups to jForum. In that case, yes you will have to do some custom work.

How work is needed depends on your needs.

Basically, the user membership is in the jforum_user_groups table that maps it jforum_users user_id key to the jforum_groups group_id key. If it's a one time thing or can be done via a cron job, then the right set of SQL scripts might work OK.

Or, you could add code to your main application to create a Jforum user id entry and matching group membership when a user is created.

Another possible option is to replace the jforum_users table and the jforum_user_groups table with an SQL view that mixes your application's info with the info required by JForum.

Finally, it is possible with a fair amount of customization to have jForum use group information from another source.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey monroe, thanks again!

I was not able to check the post as I was occupied in something else.

My applications has three types of user for which I have a corresponding group created on JForum.

I understand from your post that the changes in my application or customization are the two possiblities that will resolve my problem.

What changes do you think I need to make on my application for the JForum understand that this user needs to be created in this forum?

or

Do you have a written code to create a user on a particular group?

Thanks
Ranga
[originally posted on jforum.net by ranga]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't speak to your specific application, but the way to do it using jForum would be to have a SSO authenticateUser(request) implimentation that would take information from your application (like via a cookie or URL parameters).

Validate the request in some form, e.g. an MD5 hash of the user info that your app can generate and the jForum SSO code can recreate to verify.

If it's a valid request, then check to see if the user exists in the jForum DB. If they don't, create a matching one. (See SSOUtils.register() code).

Then you can get the information about which group this user needs to be in. This could be done by passing the info via that cookie or have the code to look up this information from your apps repostitory (e.g. a database table, LDAP server, and the like). The user could then be placed in the matching jForum group based on this.

To see the some jForum specific code for adding a user to one or more group see the UserAction.groupSave() method. This is what processes the admin add a user to a group form.

You can write this to be either a "set once" method (e.g., create user / add to current group category(ies) and doesn't change). Or it can be done to check each time a user is authenticated what group they are in and modify thier entries. (Takes more time/cpu to do this...)
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have currently managed to pass the userinfo in the cookie and create and login a user if the user is not already created or login the user if the user is already created.

The example given at http://www.jforum.net/doc/ImplementSSO, takes three parameters from the existing application: userid, password and the email. But, when I tried to compile the code, I get the following error message:

"SSOCookie.java:40: cannot find symbol
symbol : method getRequest()
location: class net.jforum.JForum
HttpSession session = JForum.getRequest().getSession();
^
1 error"

I understand that when this error is resolved, I will be able to pass the password and the email address of the user from cookie and have it create them on jForum. But, how do I associate a user to a group?

authenticateUser method returns just the userID and stores the password and email in the session from which, the jForum application creates the user.

So, now where do I call the UserAction.groupSave() method from? ( i have not myself looked at the source yet). Even if I look at it, a little is what I am going to understand.

So, if you have done something similar to my requirement please let me know.

Thanks
Ranga
[originally posted on jforum.net by ranga]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code is totally untested but should come close to what you want:


[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the code snippet you gave will be a lot useful in integrating jforum with our application.

Thanks a lot!

Will get back to you if I have any problems
[originally posted on jforum.net by ranga]
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic