LDIF

Génération d'un document LDIF en Java

public class Ldif {
 
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String[] names = nom();
		int id = 1010;
		for(int i = 0 ; i < names.length ; i++) {
			String b = bloc(names[i], id);
			System.out.println(b);
			id++;
		}
	}
 
	public static String bloc(String name, int uid) {
		String bloc="dn: uid="+name+",ou=users,ou=iut,dc=univ-lehavre,dc=fr\n"+
		"objectClass: account\n"+
		"objectClass: posixAccount\n"+
		"cn: "+name+"\n"+
		"uid: "+name+"\n"+
		"uidNumber: "+uid+"\n"+
		"gidNumber: 2000"+"\n"+
		"homeDirectory: /home/"+name+"\n"+
		"userPassword:: e0NSWVBUfWRhSDJadHI4dElnZFE=\n";
		return bloc;
	}
 
	public static String[] nom() {
		String[] res = {"michel", "stephane", "robert", "jean", "nicolas", "camille", "claire", "nathalie", "antoine", "yoann", "gaetan"};
		return res ;
	}
 
}