AnsweredAssumed Answered

custom webscript giving 500 Internal Error

Question asked by nancyaggarwal on Sep 1, 2015
Latest reply on Sep 1, 2015 by nancyaggarwal
Hi,

I am integrating my application with alfresco using external authentication. now there is a need for adding logged in user to a group in alfresco and for that i have written webscript as below:

AddUserToGroup.get.desc.xml

<webscript>



  <shortname>AddUserToGroup</shortname>



  <description>AddUserToGroup</description>



  <url>/auth/AddUserToGroup/{user}</url>



  <format default="html">argument</format>



  <authentication>user</authentication>



  <transaction>none</transaction>



</webscript>



AddUserToGroup.get.js


var paramvalue=url.extension;
var user = people.getPerson(paramvalue);



var group = people.getGroup("GROUP_test");







if (user == undefined)



{



   status.code = 404;



   status.message = "User not found";



   status.redirect = true;



}



else if (group == undefined)



{



   status.code = 404;



   status.message = "Group not found";



   status.redirect = true;



}



else



{



   people.addAuthority(group,user);



}



AddUserToGroup.get.html.ftl

<html>



   <head>



      <title>Groups</title>



   </head>



   <body>



      User assigned to group



   </body>



</html>




I am accessing the above webscript as
HttpClient client = new HttpClient();
      GetMethod method = new GetMethod("http://localhost:8080/alfresco/wcservice/auth/AddUserToGroup/test");
       method.setRequestHeader("SSO_Remote_User", test);

int statusCode = client.executeMethod(method);

if (statusCode != HttpStatus.SC_OK) {
   System.out.println(statusCode);
   return;
}
   }


but this is giving me error as 500 - Internal Error
Access Denied. You do not have the appropriate permissions to perform this operation.


I have set authentication = user then it is giving me access denied exception.


Please help me with this.


Regards,
Nancy

Outcomes