AnsweredAssumed Answered

How get the UserGroup with Web Script [Solved]

Question asked by thomasberment on Jan 20, 2011
Latest reply on Jan 26, 2011 by thomasberment
Hi,

I tried to get the user group with a web script but I had an error like : Access Denied.  You do not have the appropriate permissions to perform this operation.

He's seem correct because it's a normal user that calls the web script.

I search a solution to make a session to get my user group, because it works with user admin. An other solution will be to force the getter with admin user.

Please, help me.

Thx.

if(serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName) != null){
         Set<String> theSet = serviceRegistry.getAuthorityService().getAuthoritiesForUser(theUserName);
         if ((theSet.size() < 1) || (theSet.size() > 2)){
            this.getLogger().logTechnicalError(EnumTraitementMetierLevel.ERREUR.getCode(), "L'utilisateur est dans plusieurs groupes : " + theSet.size());
            return "";
         }else{
            String[] myElt = new String[Constantes.NB_MAX_GROUP_PER_USER];
            int i = 0;
            String theGroup = "";
            Iterator<String> it = theSet.iterator();
            while (it.hasNext()) {
                myElt[i] = (String) it.next();
                i++;
            }
            for (int j=0;j<myElt.length;j++){
               if (!Constantes.THE_GROUP_EVERYONE.equals(myElt[j])){
                  theGroup = myElt[j].substring(Constantes.INT_COUNT_WORD_GROUP);   
               }
            }
            return theGroup;
         }
      }

Outcomes