Delete users from openfire using plugin

I have been working in openfire, its plugin and strophe js for a while. I have a senario where I need to remove users every 24 hours or on certain time frame or just could call a plugin that could delete users that were created or logged out 24 hours ago. So I was thinking of creating a plugin that could do these things for me.
So here is my question how can this be done? Is there alternative solution. So in one of my plugin I have removed the user from ofUser table of openfire database upon restarting the openfire which may not be a good idea while openfire is running, so what are my option I can work on? I have been looking for a while but have not found any idea how to do it.

Thanks in advance

Hello,

I’d suggest querying the database for entries to be deleted and then submitting those to the UserService plugin for deletion.

daryl

Hey thanks for the reply daryl, I just searched more and found many ways

If we want to do it using plugin then

User user;

UserManager userManager;

userManager = server.getUserManager();

try {

user = userManager.getUser(username);

System.out.println("user is " + user.toString());

userManager.deleteUser(user);

}catch (UserNotFoundException e) {

e.printStackTrace();

}

and if you want to delete if from java code outside of plugin then using smackx.jar you could do

try {

connection = new XMPPConnection(config);

connection.connect();//establishing connection

 connection.login("user1", "user1");//user you want to delete

AccountManager AccManager = connection.getAccountManager();

AccManager.deleteAccount();//deleting the user

System.out.println(“User is deleted.”);

} catch (Exception ex) {

System.out.println("Exception in deleteUser: " + ex.toString());

}

Or there is a simpler way by calling user service url

for info visit http://www.igniterealtime.org/projects/openfire/plugins.jsp

http://example.com:9090/plugins/userService/userservice?type=delete&secret=bigse cret&username=kafka