Search the FirstSpirit Knowledge Base
Sometime users get removed from the Administrator Group, hence the plan is to run a script to add users to that group without doing it manually. here below is my initial approach.
Or any function that will give access to act as an admin to the following instructions?
element = context.getStoreElement ();
Connection con = element.getProject ().getConnection ();
Project project = con.getProjectById (pid);
List <Group> prGroup = project.getGroups ();
List <User> prUser = project.getUsers ();
List <User> adminUser = new ArrayList <User> (int i);
adminUser.add (prUser.get (int i)); // loop to add
User [] adminUsers = adminUser.toArray (new User [adminUser.size ()]); // conversion
// as the current user doesnt have admin permission hence running this method will throw Target exception: java.lang.SecurityException
project.lock ();
prGroup.get (int adminIndex) .addUsers (adminUser);
project.save ();
project.unlock ();
con.disconnet ();
Hi Rinku,
which FirstSpirit version du you use?
ConnectionManager.getConnection should work. Are you sure the user you use to connect is at least a project level admin?
Regards,
Tim
Hi RInku,
I'm afraid I didn't understand your question - I would expect that you need an admin user in order to add people to an admin group. Is this your problem?
Regards,
Hannes
Hi Hannes,
Is it possible that a user with no admin permission can have a connection to FS server as an admin (with credentials) and then add users to the administrator group? I am writing a script for such scenario. I have tried connectionManager.getConnection(parameters) / connection.getAdminService() to connect as an admin but somehow not working. have I explained clearly? please do let me know if you need more info.
Hi Rinku,
which FirstSpirit version du you use?
ConnectionManager.getConnection should work. Are you sure the user you use to connect is at least a project level admin?
Regards,
Tim
Hi Rinku,
do you need further help or did Tims's reply already help you? If so, it would be great if you marked his reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here.
Best regards
Sebastian
Hi Tim,
thanks for the clue. It works.