Hi,
I have a code to fetch the never logged in user. Can i get the login created date also?Please help to find the code for the functionality mentioned
import com.onresolve.scriptrunner.parameters.annotation.GroupPicker
import com.atlassian.crowd.embedded.api.Group
import com.onresolve.scriptrunner.parameters.annotation.*
import com.onresolve.scriptrunner.parameters.annotation.meta.*
import java.lang.String
import com.atlassian.confluence.security.login.LoginManager
import com.atlassian.confluence.user.ConfluenceUserImpl
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.GroupManager
import com.atlassian.confluence.security.PermissionManager
import com.atlassian.confluence.security.login.LoginManager
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.confluence.user.*
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.UserManager
import com.atlassian.user.security.password.Credential
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.rpc.soap.services.SpacesSoapService
import java.io.*
import groovy.lang.*
@GroupPicker(label = 'User group', description = 'The group of users to check (e.g. "confluence-users")')
Group selectedUserGroup
def groupManager = ComponentLocator.getComponent(GroupManager)
def loginManager = ComponentLocator.getComponent(LoginManager)
def userAccessor = ComponentLocator.getComponent(UserAccessor)
def userGroup = selectedUserGroup ? groupManager.getGroup(selectedUserGroup.name) : groupManager.getGroup('groupname')
// Get all users from the selected user group
def users = userAccessor.getMembers(userGroup).asList()
// Create an HTML table to display the user information
def htmlTable = "<table><tr><th>User</th><th>Last Login Date</th></tr>"
users.each { user ->
def lastLoginInfo = loginManager.getLoginInfo(user)
if (!lastLoginInfo?.lastSuccessfulLoginDate && !userAccessor.isDeactivated(user)) {
// User has never logged in and is active
htmlTable += "<tr><td>${user.name}</td><td>Never logged in</td></tr>"
}
}
htmlTable += "</table>"
return htmlTable
Hi @Ankit Choudhary I would recommend to use the sql query to be used in the script to get the last login and account created data for the users in Confluence
I am not able to put this sql query in the comment as getting the HTML error so please check the attached screenshot for the sql query and sucessdate as per your requirement.
Thanks
Ravina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.