Bonjour à tous,

J'aimerais utiliser JNDI pour nourrir un annuaire LDAP, mais j'ai toujours droit au même message d'erreur:

javax.naming.directory.InvalidAttributeIdentifierException: [LDAP: error code 17 - dn: attribute type undefined];

J'ai déja eu cette erreur, mais elle était simplement du à une faute de frappe. Si j'utilise la commande ldapadd avec un fichier texte au format ldif, ça fonctionne normalement. Voici mon fichier ldif:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
dn: uid=geleludovic15051976,ou=people,dc=amiens,dc=iufm,dc=fr
sn: Gele
givenName: Ludovic
cn: Gele Ludovic
displayName: Ludovic Gele
uid: geleludovic15051976
title: ASI
mail: ludovic.gele@amiens.iufm.fr
userPassword: azerty
postalAddress: 21 rue Jean Jaures$80480 Saleux
labeledURI: none
preferredLanguage: fr
telephoneNumber: +33322535961
facsimileTelephoneNumber: none
mobile: telephone mobile
eduPersonAffiliation: member
eduPersonPrimaryAffiliation: employee
eduPersonNickname: Ludo
eduPersonPrincipalName: identifiant ENT
supannAliasLogin: loginGele
supannOrganisme: 0801885P
supannCivilite: M.
supannRole: GROUPE-LOGICIEL
supannListeRouge: FALSE
supannAutreTelephone: +33322535980
supannAffectation: Service Informatique
supannEmpId: 2567
supannCodeINE: 0000000000g
supannEtuId: etudIdGele
supannParrainDN: cn=admin,dc=amiens,dc=iufm,dc=fr
objectclass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: eduPerson
objectClass: supannPerson
En ce qui concerne le code pour créer une nouvelle entrée dans l'annuaire, j'ai suivi un tuto sur le site javaworld. J'ai créer une classe User comme suis:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
public class User implements DirContext{
 
 
        Attributes myAttrs = new BasicAttributes(true);
        Attribute oc = new BasicAttribute("objectclass");
        Attribute ouSet = new BasicAttribute("ou");
 
    private String dn;
 
        public User(String dn, String sn, String givenname, String cn, String displayName, String uid, String title,
                String mail, String userPassword, String postalAddress, String labeledURI, String preferredLanguage,
                String telephoneNumber, String facsimileTelephoneNumber, String mobile, String eduPersonAffiliation,
                String eduPersonPrimaryAffiliation, String eduPersonNickname, String eduPersonPrincipalName,
                String supannAliasLogin, String supannOrganisme, String supannCivilite, String supannRole,
                String supannListeRouge, String supannAutreTelephone, String supannAffectation, String supannEmpId,
                String supannCodeINE, String supannEtuId, String supannParrainDN){
            this.dn=dn;
 
            oc.add("person");
            oc.add("organizationalPerson");
            oc.add("inetOrgPerson");
            oc.add("eduPerson");
            oc.add("supannPerson");
            ouSet.add("People");
 
            myAttrs.put(oc);
            myAttrs.put(ouSet);
            myAttrs.put("dn",dn);
            myAttrs.put("sn",sn);
            //etc, pour chaque attribut...
        }
et je l'appel dans ma fonction main:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
DirContext ctx = new InitialDirContext(env);
 
            User p1 = new User("uid=geleludovic15051976, ou=people, dc=amiens, dc=iufm, dc=fr","Gélé","Ludovic",
                    "Gele Ludovic","Ludovic Gélé","geleludovic15051976","ASI","ludovic.gele@amiens.iufm.fr","azerty",
                    "21 rue Jean Jaures$80480 Saleux","none","fr","+33322535961","none","0625987458",
                    "member","employee","Ludo","identifiantENT","loginGele","0801885P","M.","none",
                    "TRUE","+33322535980","Service Informatique","2567","0000000000g",
                    "etudIdGele","cn=admin,dc=amiens,dc=iufm,dc=fr");
            ctx.bind("uid=geleludovic15051976, ou=people, dc=amiens, dc=iufm, dc=fr", p1);
            ctx.close();
D'après google et la doc java, l'erreur 17 est du au fait que l'attribut n'est pas défini dans le schéma de l'annuaire. J'ai bien vérifier que c'était le cas, j'ai essayé de retirer tout les caractères accentué des attributs et re-vérifié mon code pour essayer de trouver des fautes de frappe, mais je ne vois rien.

D'avance merci beaucoup pour toute aide et suggestions.

PS:Je bosse sous netbeans 5.0, avec une jvm 1.5 sous windows XP. Mon système est à jour