IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API standards et tierces Java Discussion :

[LDAP] value of naming attribute 'cn' is not present in entry


Sujet :

API standards et tierces Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut [LDAP] value of naming attribute 'cn' is not present in entry
    Bonjour,

    J'ai une erreur assez embettante depuis hier car je ne peu insérer des données au sein de mon serveur LDAP voici la cause :

    Error: LDAPException: Naming Violation (64) Naming Violation
    LDAPException: Server Message: value of naming attribute 'cn' is not present in entry
    LDAPException: Matched DN:
    A savoir que mon dn en entrée est : "cn=XYZ,ou=baba,ou=bobo,dc=toto,dc=fr" et mon cn en entrée qui reprend bien le cn de mon dn "XYZ"

    A savoir que j'ai créer ma propre classe sous ldap et que je fais dériver ma classe d'inetorgperson qui hérite elle meme d'organizationalperson et de person. la classe person a comme attributs obligatoires cn.

    Donc en toute logique on doit lui passer un cn , chose que je fais mais qui malheuresement abouti a ce message d'erreur

    J'utilise la librairie Novell pour me connecter et manipuler les données, voici le code pour insérer le cn :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    attributeSet.add( new LDAPAttribute("cn", attributs[68]));
    je passe tout mes attributs dans le tableau

    J'avais vu sur des forums comme quoi ce type d'erreur etait lié au fait qu'on ne mettait pas la bonne valeur au "cn" mais là apparement ce n'est pas le cas, mais j'ai quand meme cette erreur ..

    si vous voyez une solution merci d'avance!

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut
    un ptit up en apportant du nouveau :

    Alors j'ai remarqué que ma premiére entrée se créé bien mais que les suivantes elle par contre me ressortait la meme erreur du cn, j'affiche avant mon dn et cn pour bien vérifier qu'il sois correct

    dn : cn=XYZ,ou=baba,ou=bobo,dc=toto,dc=fr
    cn : XYZ
    Ajout de l'entrée: cn=XYZ,ou=baba,ou=bobo,dc=toto,dc=fr est enregistrée.

    dn : cn=ZYX,ou=baba,ou=bobo,dc=toto,dc=fr
    cn : ZYX
    Error: LDAPException: Naming Violation (64) Naming Violation
    LDAPException: Server Message: value of naming attribute 'cn' is not present in entry
    LDAPException: Matched DN:

    etc...

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut
    hmm personne ?

  4. #4
    Membre éprouvé
    Profil pro
    Inscrit en
    Février 2006
    Messages
    124
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 124
    Par défaut
    J'ai comparé ce que j'avais utilisé avec ton code et ça me semble pareil... tu es sûr que tu n'as pas déjà une entrée avec ce cn par exemple dans LDAP? Je sais pas si ça pourrait créer un problème comme ça mais on ne sait jamais.

    Ce que tu peux essayer c'est d'inverser tes 2 premières insertions et voir si la 1ère échoue et la seconde réussi.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut
    Citation Envoyé par yizashi
    J'ai comparé ce que j'avais utilisé avec ton code et ça me semble pareil... tu es sûr que tu n'as pas déjà une entrée avec ce cn par exemple dans LDAP? Je sais pas si ça pourrait créer un problème comme ça mais on ne sait jamais.

    Ce que tu peux essayer c'est d'inverser tes 2 premières insertions et voir si la 1ère échoue et la seconde réussi.
    merce pour ta réponse !

    alors je viens de tester et cela fait comme avant à savoir la premier enregistrement fonctionne bien, mais les suivants la meme erreur qui reviens

    sinon pour répondre à ta premiére question, mon serveur LDAP est vide donc il ne peu pas avoir 2 entrées identique.

    dn : cn=777,ou=baba,ou=bobo,dc=toto,dc=fr
    cn : 777
    Ajout de l'entrée: cn=777,ou=baba,ou=bobo,dc=toto,dc=fr est enregistrée.

    dn : cn=888,ou=baba,ou=bobo,dc=toto,dc=fr
    cn : 888
    Error: LDAPException: Naming Violation (64) Naming Violation
    LDAPException: Server Message: value of naming attribute 'cn' is not present in entry
    LDAPException: Matched DN:

  6. #6
    Membre éprouvé
    Profil pro
    Inscrit en
    Février 2006
    Messages
    124
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 124
    Par défaut
    Moi j'avais utilisé des fichiers ldif pour ajouter mes entrées (avec ADAM), je l'ai jamais fait avec une librairie. Tu dois surement faire une erreur à ce niveau.

    Comme tu fais ça par programmation, tu dois surement pouvoir te remettre dans un état identique à celui qui précède la 1ère insertion. Faudrait essayer en tous cas, quelque chose doit changer entre l'ajout de la 1ère et la 2ème entrée et ce n'est pas que la valeur des attributs.

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut
    bon ba toujours pas trouvé la cause de ce probléme alors, attention aux yeux : ajout de mes sources ^^

    j'espere que qqun pourra voir si il y a une erreur qq part et qui engendre mon erreur

    la classe AnalyseDelta a pour principal but de lire un fichier texte qui correspond a peu pres à un fichier LDIF, elle décortique chaque personne se trouvant dans ce fichier texte en prenant son dn et ses attributs qu'elle transmet à la classe ServiceLDAP.

    Classe AnalyseDelta
    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
     
    public class AnalyseDelta {
     
    	public static String FichierDeltaTestCharge = "//cheminfichier.txt";
    	public static String containerName;
    	public static String[] attributs;
    	public static String dn;
    	public static String utilisateur;
     
    	public void LireDelta()
    	{
    		ServiceLdap sl = new ServiceLdap();
    		String entitee="";
    		String line="",LineDebut="",LineChangeType="",LineFin="",ChangetypeMode="";
    		String adr1="",adr2="",adr3="",adr4="",adr5="",nom="",prenom="";
    		String affec1="",affec2="",affec3="",affec4="",affec5="",civilite="",codeaffec="",codece="",codecentrefrais="",codeefs="",codemploi="";
    		String struct1="",struct2="",struct3="",struct4="",struct5="",struct6="",struct7="",struct8="",cptprincipal="",datedeb="",datefin="";
    		String degre="",fonction="",identback="",identifiant="",identhierar="",libaffec="",libcentre="",libentite="",liblieugeo="",liblongstrn1="";
    		String liblongstrn2="",liblongstrn3="",libsociete="",libstruct1="",libstruct2="",libstruct3="",libstruct4="",libstruct5="";
    		String libstruct6="",libstruct7="",libstruct8="",lieugeotra="",mail="",memoid="",numpc="",numsalarie="",profil1="",profil2="";
    		String profil3="",profil4="",profil5="",teldirect="",telfax="",telportable="",telsecretariat="",typecontrat="";
    		int j=0,x=0;
    		try
    		{
    			BufferedReader b = new BufferedReader(new FileReader(FichierDeltaTestCharge));
    			try{
    				while(b.ready()) {  // tant que le fichier n'est pas finit
    					line=b.readLine();				
    					if(line.length()>17){identhierar=line.substring(0,18);}
    					if(line.length()>15){codecentrefrais=codeaffec=affec1=affec2=affec3=affec4=affec5=LineFin=line.substring(0,16);}
    					if(line.length()>15){struct1=struct2=struct3=struct4=struct5=struct6=struct7=struct8=line.substring(0,16);}
    					if(line.length()>14){libstruct1=libstruct2=libcentre=libaffec=datefin=datedeb=line.substring(0,15);}
    					if(line.length()>14){telsecretariat=libstruct3=libstruct4=libstruct5=libstruct6=libstruct7=libstruct8=line.substring(0,15);}
    					if(line.length()>13){liblieugeo=adr5=adr4=adr3=adr2=adr1=line.substring(0,14);}
    					if(line.length()>12){liblongstrn1=liblongstrn2=liblongstrn3=cptprincipal=line.substring(0,13);}
    					if(line.length()>11){typecontrat=identifiant=identback=line.substring(0,12);}
    					if(line.length()>10){telportable=numsalarie=lieugeotra=libsociete=LineChangeType=line.substring(0,11);}
    					if(line.length()>9){teldirect=libentite=codemploi=line.substring(0,10);}
    					if(line.length()>8){fonction=civilite=line.substring(0,9);}
    					if(line.length()>7){profil1=profil2=profil3=profil4=profil5=codeefs=line.substring(0,8);}
    					if(line.length()>6){telfax=memoid=codece=prenom=LineDebut=line.substring(0,7);}
    					if(line.length()>5){numpc=degre=line.substring(0,6);}
    					if(line.length()>4){mail=line.substring(0,5);}
    					if(line.length()>3){nom=line.substring(0,4);}
     
    					if(LineDebut.equals("dn: CN=") == true) //detecte si nous sommes au debut d'un utilisateur
    					{
    						StringTokenizer st = new StringTokenizer(line,"=,");
    						st.nextToken();
    						utilisateur = st.nextToken();
    						st.nextToken();st.nextToken();st.nextToken();
    						entitee = st.nextToken();
    						dn = "uid=" + utilisateur + ",ou=personnel," + "ou=" + entitee + "," + containerName;
    					}
    					if(LineChangeType.equals("changetype:") == true) //detecte le changetype
    					{
    						StringTokenizer st0 = new StringTokenizer(line," ");
    						st0.nextToken();
    						ChangetypeMode = st0.nextToken();
    						if(ChangetypeMode.equals("add") == true)
    						{
    							j=1;
    						}
    						if(ChangetypeMode.equals("delete") == true)
    						{
    							j=2;
    						}
    						if(ChangetypeMode.equals("Mask") == true)
    						{
    							j=3;
    						}
    						if(ChangetypeMode.equals("Modify") == true)
    						{
    							j=4;
    						}
    					}
    					if(j == 1) // procédure d'ajout d'une personne
    					{
    						if(adr1.equals("ADRLIEUGEOTRA1:") == true)
    						{
    							StringTokenizer st1 = new StringTokenizer(line);
    							st1.nextToken();
    							while((st1.hasMoreTokens()))
    								attributs[2] = attributs[2] + " " + st1.nextToken();
    						}
    						if(adr2.equals("ADRLIEUGEOTRA2:") == true)
    						{
    							StringTokenizer st1 = new StringTokenizer(line);
    							st1.nextToken();
    							while((st1.hasMoreTokens()))
    								attributs[3] = attributs[3] + " " + st1.nextToken();
    						}
    						if(adr3.equals("ADRLIEUGEOTRA3:") == true)
    						{
    							StringTokenizer st1 = new StringTokenizer(line);
    							st1.nextToken();
    							while((st1.hasMoreTokens()))
    								attributs[4] = attributs[4] + " " + st1.nextToken();
    						}
    						if(adr4.equals("ADRLIEUGEOTRA4:") == true)
    						{
    							StringTokenizer st1 = new StringTokenizer(line);
    							st1.nextToken();
    							while((st1.hasMoreTokens()))
    								attributs[5] = attributs[5] + " " + st1.nextToken();
    						}
    						if(adr5.equals("ADRLIEUGEOTRA5:") == true)
    						{
    							StringTokenizer st1 = new StringTokenizer(line);
    							st1.nextToken();
    							while((st1.hasMoreTokens()))
    								attributs[6] = attributs[6] + " " + st1.nextToken();
    						}
     
    ...
    ... 
    ...
     
    						if(LineFin.equals("FinCollaborateur") == true)
    						{
    							x=1;
    						}
     
    						if(x == 1)
    						{
    							int i;
    							attributs[7] = attributs[2]+attributs[3]+attributs[4]+attributs[5]+attributs[6];
    							//rajout d'un cn car la classe person de LDAP necessite l'attribut cn (common name)
    							attributs[68] = utilisateur;
    							for(i=0;i<attributs.length;i++)
    							{
    								if((attributs[i].equals(" ") || attributs[i].equals("     ")) == false)
    								{
    									attributs[i]=attributs[i].trim();
    								}
    							}
     
    							sl.AjouterPersonne(attributs,dn);
     
    							for(i=0;i<attributs.length;i++)
    					        	attributs[i]=" ";
     
    							j=x=0;
    						}
    					}
    					if(j==2)
    					{
    						sl.EnleverPersonne(dn);
    					}
    				} 
    			}
    			finally
    			{
    				b.close();
    			}
    		}
    		catch(IOException ioe) 
    		{
    			System.err.println("IO erreur :" + ioe);
    		}
    	}
     
    	public AnalyseDelta()
    	{
            containerName  = "XXX";
            attributs = new String[70];
            int i = 0;
            for(i=0;i<attributs.length;i++)
            	attributs[i]=" ";
    	}
     
    	public static void main(String[] args)
        {
                AnalyseDelta lp = new AnalyseDelta();
                lp.LireDelta();
       }
    Classe ServiceLDAP

    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    public class ServiceLdap {
     
    	public static int ldapPort;
    	public static int ldapVersion;
    	public static String ldapHost;
    	public static String loginDN;
    	public static String password;
    	public static String containerName;
    	public static LDAPConnection lc;
    	public static LDAPAttribute attribute;
    	public static LDAPAttributeSet attributeSet;
     
    	public ServiceLdap() {
     
    	ldapPort = LDAPConnection.DEFAULT_PORT;
            ldapVersion  = LDAPConnection.LDAP_V3;
            ldapHost       = "XXX";
            loginDN        = "XXX";
            password       = "XXX";
            containerName  = "XXX";
            lc = new LDAPConnection();
            attribute = null;
            attributeSet = new LDAPAttributeSet();
     
    	}
     
    	public void AjouterPersonne(String[] attributs, String dn)
    	{
    	System.out.println("dn : " + dn);
    	System.out.println("uid : " + attributs[34]);
    	System.out.println("cn : " + attributs[68]);
     
    	attributeSet.add( new LDAPAttribute("objectclass", new String("personCM")));
            attributeSet.add( new LDAPAttribute("adrlieugeotra1", attributs[2]));               
            attributeSet.add( new LDAPAttribute("adrlieugeotra2", attributs[3]));        
            attributeSet.add( new LDAPAttribute("adrlieugeotra3", attributs[4]));        
            attributeSet.add( new LDAPAttribute("adrlieugeotra4", attributs[5]));                                                     
            attributeSet.add( new LDAPAttribute("adrlieugeotra5", attributs[6]));
            ...
            attributeSet.add( new LDAPAttribute("uid", attributs[34]));        
            ...
    	attributeSet.add( new LDAPAttribute("cn", attributs[68]));
     
            LDAPEntry newEntry = new LDAPEntry( dn, attributeSet );
     
            try {
               // connect to the server
                lc.connect( ldapHost, ldapPort );
     
                lc.bind( ldapVersion, loginDN, password.getBytes("UTF8") );
     
                lc.add( newEntry );
                System.out.println( "\nAjout de l'entrée: " + dn + " est enregistrée." );
     
                lc.disconnect();
            }
            catch( LDAPException e ) {
                System.out.println( "Erreur:  " + e.toString());
            }
            catch( UnsupportedEncodingException e ) {
                System.out.println( "Erreur: " + e.toString() );
            }
    	}
     
    	public void EnleverPersonne(String dn) // enleve une personne si 
    	{
    		try 
    		{
    			lc.connect( ldapHost, ldapPort );
     
    			lc.bind( ldapVersion, loginDN, password.getBytes("UTF8") );
     
    			lc.delete( dn );
     
    			System.out.println( "\nL'entrée: " + dn + " est détruite." );
     
    			lc.disconnect();
    		}
    		catch( LDAPException e ) 
    		{
    			if ( e.getResultCode() == LDAPException.NO_SUCH_OBJECT )
    				System.err.println( "Erreur: L'entrée n'existe pas" );
    			else if ( e.getResultCode() == LDAPException.INSUFFICIENT_ACCESS_RIGHTS )
    				System.err.println( "Erreur: Vous n'avez pas les permissions" );
    		    else
    		        System.err.println( "Erreur: " + e.toString() );
    		}        
    		catch( UnsupportedEncodingException e ) 
    		{
    			System.out.println( "Erreur: " + e.toString() );
    		}
    	}
    }

  8. #8
    Membre averti
    Profil pro
    Inscrit en
    Mai 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2006
    Messages : 25
    Par défaut
    up

  9. #9
    Membre éprouvé Avatar de shaun_the_sheep
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Octobre 2004
    Messages
    1 619
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2004
    Messages : 1 619
    Par défaut
    Salut,

    Désolé de ne pas t'avoir aidé avant, je rentre de vacances , ton problème est très bizard.

    c'est pas un problème de doublon c'est sur car le message serait très explicite.

    tu précises un objectClass propriétaire, hors as tu tester l'ajout en masse d'enregistrement simple de type inetOrgPerson avec juste le minimun ?

    as tu le même resultat ?

    as tu testé un insert via le code sans passer pas une boucle, mais ligne pas ligne en forcant les infos ?

    as tu la aussi le même resultat ?

    as tu aussi testé l'insert dans ton annuaire d'entrée via un outil style Jxplorer (browser ldap très bien) ?

    Merci

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 9
    Par défaut Interroger LDAP avec javascript
    Salut a tous,

    Mon problème est le suivant : je veux savoir si il est possible de consulter un annuaire LDAP avec javascript. par exemple je donne l'UID d'un utilisateur et j'affiche ses informations.
    En fait je veux savoir si il est possible de faire appel à la commande (en mode consol sous Ubuntu) "ldapsearch" à) l'aide de javascript.

    Merci d'avance!!

  11. #11
    in
    in est déconnecté
    Membre Expert Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Par défaut
    Citation Envoyé par Bouhaouala

    En fait je veux savoir si il est possible de faire appel à la commande (en mode consol sous Ubuntu) "ldapsearch" à) l'aide de javascript.
    Quel est le rapport avec ce topic ??

    Pourquoi ne pas poser cette question dans le forum javascript ??

Discussions similaires

  1. Réponses: 4
    Dernier message: 11/03/2010, 17h02
  2. LDAP: recherche sur un attribut multivalué
    Par yjuliet dans le forum Sécurité
    Réponses: 1
    Dernier message: 13/10/2008, 17h59
  3. [xslt 1.0] - distinct value sur un attribut
    Par jacquesh dans le forum XSL/XSLT/XPATH
    Réponses: 1
    Dernier message: 30/10/2007, 07h38
  4. Réponses: 3
    Dernier message: 30/06/2007, 10h55
  5. [XSLT] value-of dans attribut html ?!
    Par ghohm dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 30/08/2006, 16h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo