try {
  def session = request.getAuthSession(true)

  def emailFromAssertion = session.getAttribute('emailFromAssertion') ?: 'unknown'
  def subjectFromAssertion = session.getAttribute('ch.nevis.auth.saml.assertion.subject') ?: 'unknown'
  def loginId = inargs.getProperty('isiwebuserid') ?: 'unknown'
  def sourceIp = request.getLoginContext()['connection.HttpHeader.X-Real-IP'] ?: 'unknown'
  def userAgent = request.getLoginContext()['connection.HttpHeader.user-agent'] ?: request.getLoginContext()['connection.HttpHeader.User-Agent'] ?: 'unknown'

  LOG.warn("Event='IDM-ADMIN-LOGIN', subject from assertion=${subjectFromAssertion}, email from assertion='${emailFromAssertion}', loginId=${loginId}, SourceIp=${sourceIp}, UserAgent='${userAgent}')")
  response.setResult('ok');
} catch(Exception ex) {
   LOG.error("Exception in logLoginUser groovy script: " + ex)
   response.setResult('error');
}
