The best way is using @Grab to download in Runtime the LDAP library from Apache.org servers.
@GrabResolver(name='apache-snapshot', root='http://repository.apache.org/snapshots/') @Grab(group='org.apache.directory', module='groovyldap', version='0.1-SNAPSHOT') import org.apache.directory.groovyldap.* log.setLevel(org.apache.log4j.Level.DEBUG) log.debug "Connecting EXAMPLE LDAP..." ldap = LDAP.newInstance('ldap://server:port/', 'CN=LDAP User, CN=Users,DC=example,DC=com', '******') log.debug "Connection completed" log.debug "Verifying if Raul Pelaez exists in the 9th dimension...." exists = ldap.exists('cn=Raul Pelaez,dc=example,dc=com') if (exists) { log.debug "Yes... he exists!" log.debug "Searching users" results = ldap.search('(objectClass=user)', 'DC=example,DC=com', SearchScope.SUB ) log.debug "# Entries found: ${results.size}" //for (entry in results) { // log.debug "User: "+ entry.cn; // break; //} } /* ADD NEW USER heather = [ objectclass: ['top', 'person'], sn: 'Nova', cn: 'Heather Nova' ] ldap.add('cn=Heather Nova,dc=example,dc=com', heather) */ /* MODIFY NEW USER dn = 'cn=Heather Nova,dc=example,dc=com' // Adding a single attribute descr = [ description: 'a singer-songwriter' ] ldap.modify(dn, 'ADD', descr) // performing two operations atomically mods = [ [ 'REPLACE', [description: 'a singer-songwriter, born in Bermuda'] ], [ 'ADD', [userPassword: 'secret'] ] ] ldap.modify(dn, mods) */
i want to send mail alert to jira user who is not logged in last 30 days which sholud be automatic mail alert system how to write the groovy code or any polugins to this
LikeLike
Hi Mahendar,
Please use a mix with these lines:
import com.atlassian.jira.security.login.LoginManager
import com.atlassian.jira.security.login.LoginInfo
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
Long lastLoginTime = loginManager.getLoginInfo(user.name).getLastLoginTime()
And to obtain the users of the Jira Directory (and send a mail):
– https://mraddon.blog/2018/02/03/jira-groovy-script-to-send-a-mail-to-jira-groups/
And to send a mail using groovy:
– https://mraddon.blog/2018/02/11/jira-groovy-postfunction-to-send-a-mail-with-the-description-content-of-the-issue-in-html/
Best regards
LikeLike