Before I go to plugin, I've managed to solve this using simple groovy
script and using linux tool ssmtp.
Example of script is below. Actually the script create one temporary txt
file which is then used by ssmtp tool for sending email.
For now I'm using such script in one dataset which is called on create
values within configuration of lsc.xml.

import java.io.File

def generator() {
    String alphabet = (('A'..'Z')+('0'..'9')+('a'..'z')).join()
    int n = 12
    String puk
    puk = new Random().with {
    (1..n).collect { alphabet[ nextInt( alphabet.length() ) ] }.join()
    }
    String ime = srcBean.getDatasetFirstValueById("ime")
    String priimek = srcBean.getDatasetFirstValueById("priimek")
    String username = srcBean.getDatasetFirstValueById("samaccountname")
    String pass = "Passw0rd!" +
srcBean.getDatasetFirstValueById("employeeid")


    new File('/tmp/mail.txt').withWriter('utf-8') {
        writer ->
        writer.writeLine "Subject: New user " + username
        writer.writeLine "From: [email protected]"
        writer.writeLine "Content-type: text/html; charset=\"utf8\""
        writer.writeLine "<html>"
        writer.writeLine "<body>"
        writer.writeLine "Name: " + ime
        writer.writeLine "<br>"
        writer.writeLine "Surname: " + priimek
        writer.writeLine "<br>"
        writer.writeLine "Username: " + username
        writer.writeLine "<br>"
        writer.writeLine "Password: " + "<b>" + pass + "</b>"
        writer.writeLine "<br>"
        writer.writeLine "PUK code: " + "<b>" + puk + "</b>"
        writer.writeLine "</html>"
        writer.writeLine "</body>"

    }

  //send mail
  def p = ['sh','-c','ssmtp [email protected] < /tmp/mail.txt'].execute()
  p.waitFor()
  println p.text

  //Remove TXT file
  def r = ['sh','-c','rm -f /tmp/mail.txt'].execute()
  r.waitFor()
  println r.text

  return puk
}

Regards,
Matjaž


V V sob., 22. sep. 2018 ob 19:50 je oseba Clément OUDOT <
[email protected]> napisala:

>
>
> Le 21/09/2018 à 22:28, Matjaz Premerl a écrit :
> > Hi,
> >
> > I want to create some files while the lsc synchronization is working.
> > Is there any approach how to write the file with java script together
> > with node.js? Or is there even some better way how to do this. My
> > final requirement is to write in the file data like username,
> > firstname, lastname, etc.
> >
>
> I think the best is to use the LSC executable plugin, then you can write
> you own scripts to deal with files.
>
> See https://lsc-project.org/documentation/plugins/executable
>
> See also some perl scripts that read a CSV file:
> https://github.com/lsc-project/lsc-executable-plugin/tree/master/scripts
>
>
> --
> Clément Oudot | Identity Solutions Manager
>
> [email protected]
>
> Worteks | https://www.worteks.com
>
> _______________________________________________________________
> Ldap Synchronization Connector (LSC) - http://lsc-project.org
>
> lsc-users mailing list
> [email protected]
> https://lists.lsc-project.org/cgi-bin/mailman/listinfo/lsc-users
_______________________________________________________________
Ldap Synchronization Connector (LSC) - http://lsc-project.org

lsc-users mailing list
[email protected]
https://lists.lsc-project.org/cgi-bin/mailman/listinfo/lsc-users

Reply via email to