Hi Stuart

I've managed to figure out how to get your code working. Staff and students
are now automatically being added to special groups in DSpace.

When I get the time I'll add the process I followed to my DSpace blog.

Thanks very much indeed :D

Clive

On Tue, Apr 28, 2009 at 12:32 AM, Stuart Lewis <s.le...@auckland.ac.nz>wrote:

> Hi Clive,
>
> Try replacing the code in the getSpcialGroups method in
> [dspace-src]/dspace-api/src/main/java/org/dspace/authenticate/DAPHierarchicalAuthentication.java
> with the following:
>
> public int[] getSpecialGroups(Context context, HttpServletRequest request)
> {
>    try
>    {
>        if (!context.getCurrentUser().getNetid().equals(""))
>        {
>            Group staffGroup = Group.findByName(context, "all-staff");
>            Group studentsGroup = Group.findByName(context, "all-students");
>
>            // Does the username start with a '1'?
>            if ((studentsGroup != null) &&
> (context.getCurrentUser().getNetid().startsWith("1")))
>            {
>                // Add them to the students group
>                return new int[] { studentsGroup.getID() };
>            }
>            else if (staffGroup != null)
>            {
>                // Add them to the staff group
>                return new int[] { staffGroup.getID() };
>            }
>        }
>    }
>    catch (Exception npe) {
>        // The user is not an LDAP user, so we don't need to worry about
> them
>    }
>    return new int[0];
> }
>
> Hopefully this should work. You may wish to change the group names which
> are set in the code to be 'all-staff' and 'all-students'.
>
>
>
> Stuart Lewis
> Digital Services Programmer
> Te Tumu Herenga The University of Auckland Library
> Auckland Mail Centre, Private Bag 92019, Auckland 1142, New Zealand
> Ph: 64 9 373-7599 x81928
> http://www.library.auckland.ac.nz/
>
>
>
>
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to