Hello People,
 I have suddenly become an excited user of the slide framework.
 I am currently working with the slide for a life project.
 However, I have an issue here.
 How do one create a new user and assign role to the new user. I have tried to do this
 with the code below.
 Yes it creates the user's structure but when I try to use the new user to perform an 
action I get the error => org.apache.slide.security.AccessDeniedException: Access 
denied on /users by user /users/Gbenga for action /actions/bind
 at org.apache.slide.security.SecurityImpl.checkCredentials(SecurityImpl.java:397)
 at org.apache.slide.structure.StructureImpl.create(StructureImpl.java:316)
 at com.onespace.webdav.Smysqlstore.CreateNewUser(Smysqlstore.java:577)
 at com.onespace.webdav.Smysqlstore.main(Smysqlstore.java:1008)

Please could anyone enligthen me on how to go about this issues
-Create New User
-Create new roles in slide
-Asign role to the user.
I am using slide 2.0
mysql 4.0.12 as my content store.
Running windows 2000
I hope to have your contribution today
Thank you in advance
COGI Gbenga
=====================================================================================
  public void CreateNewUser(String UserName, String Useradmin,
                            String Roletype) throws Exception{
    //Package authentication token
    CredentialsToken credentials = new CredentialsToken(Useradmin);
    SlideToken slidetoken = new SlideTokenImpl(credentials);
    SubjectNode userSubjectNode = new SubjectNode();
    String newuser = "/users/"+UserName;
    try{
      structure.retrieve(slidetoken,newuser);
      assignRole(newuser,Roletype,slidetoken);
    }catch(StructureException SExc){
      token.begin();
      structure.create(slidetoken,userSubjectNode,newuser);
      assignRole(newuser,Roletype,slidetoken);
      token.commit();
      //addPermision
    }
  }
======================================================================================
  public void assignRole(String SubjectURI, String roleType,
                         SlideToken slidetoken) throws Exception{
    String RoletoAsssign = "/roles/"+roleType;
    try{
      token.begin();
      structure.retrieve(slidetoken, RoletoAsssign);
      NodeRevisionDescriptors NrDescriptors = null;
      NodeRevisionDescriptor nodeDescriptor = null;
      NrDescriptors= content.retrieve(slidetoken,RoletoAsssign);
      nodeDescriptor = content.retrieve(slidetoken,NrDescriptors);
      //Enumerate Properties
      Enumeration descriptorenum = nodeDescriptor.enumerateProperties();
      boolean breakout =false;
      String compare="group-member-set";
      String ppt_to_update =null;
      String Val_to_update = null;
      while (descriptorenum.hasMoreElements() &&!breakout){
        NodeProperty ppt = (NodeProperty)descriptorenum.nextElement();
        if (compare.compareTo(ppt.getName()) ==0){
          breakout = true;
          ppt_to_update = ppt.getName();
          Val_to_update = (String)ppt.getValue();
          Val_to_update = Val_to_update + "<D:href xmlns:D='DAV:'>"
              +SubjectURI+"</D:href>";
          nodeDescriptor.setProperty(ppt_to_update,Val_to_update);
          token.commit();
        }
        System.out.println("Property => "+ppt.getName()+ " = " + ppt.getValue());
      }
    }catch(Exception exp){
      System.err.println("The URI "+RoletoAsssign+" does not exist");
      exp.printStackTrace();
    }
  }
=======================================================================================


                
---------------------------------
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs 

Reply via email to