# LDAP Attribut Problem



## RoliMG (7. Nov 2006)

hallo leute!
ich versuche zur zeit über jldap einem eintrag bestimmte attribute hinzuzufügen. verwendet wird ein netware novell server version 6.5, und der zugriff erfolgt über die novell api jldap.
mein problem:
wenn ich bestimmte attribute dem ldapentry hinzufüge, und diesen anschließend dem verzeichnis hinzufügen will, tritt eine ldapexception mit der meldung "Object Class Violation (65)" auf.
die folgenden attribute sind davon betroffen:

loginShell
gidNumber
uidNumber
ndsHomeDirectory
homeDirectory

die objektklassen habe ich meiner meinung nach korrekt hinzugefügt aber seht selbst:


```
String loginname = login.getLogin();
String vorname = login.getFeld(vnamespalte);
String zuname = login.getFeld(nachnamespalte);
//String id = login.getFeld(idspalte);
String pwd = login.getPasswort();
LDAPAttributeSet set = new LDAPAttributeSet();
String dn = login.getDN();
		
set.add(new LDAPAttribute("givenName", vorname));
set.add(new LDAPAttribute("fullName", zuname + " " + vorname));
set.add(new LDAPAttribute("Language", "Deutsch"));
set.add(new LDAPAttribute("sn", zuname));
set.add(new LDAPAttribute("passwordRequired", "TRUE"));
set.add(new LDAPAttribute("passwordMinimumLength", "5"));
set.add(new LDAPAttribute("passwordAllowChange", "TRUE"));
set.add(new LDAPAttribute("objectClass", "inetOrgPerson"));
set.add(new LDAPAttribute("objectClass", "organizationalPerson"));
set.add(new LDAPAttribute("objectClass", "person"));
set.add(new LDAPAttribute("objectClass", "top"));
set.add(new LDAPAttribute("objectClass", "ndsLoginProperties"));
set.add(new LDAPAttribute("objectClass", "posixAccount"));
set.add(new LDAPAttribute("loginScript", "rem"));
set.add(new LDAPAttribute("loginMaximumSimultaneous", "1"));
set.add(new LDAPAttribute("loginDisabled", "FALSE"));
set.add(new LDAPAttribute("uid", loginname));
//set.add(new LDAPAttribute("loginShell", "/bin/bash")); Hier fangen die Probleme an
//set.add(new LDAPAttribute("gidNumber", "100"));
//set.add(new LDAPAttribute("uidNumber", id));
//set.add(new LDAPAttribute("ndsHomeDirectory", "cn=HOM1_H3,ou=SERVER,o=HTL#0#06"));
//set.add(new LDAPAttribute("homeDirectory", "/home/" + login));
set.add(new LDAPAttribute("cn", loginname));
set.add(new LDAPAttribute("userpassword", pwd));

LDAPEntry ent = new LDAPEntry(dn, set);
		
try
{
	con.add(ent);
}
catch (LDAPException e)
{
	System.out.println("Problem: " + loginname);
	e.printStackTrace();
}
```

hier noch der stacktrace:

LDAPException: Object Class Violation (65) Object Class Violation
LDAPException: Server Message: NDS error: illegal attribute (-608)
LDAPException: Matched DN: 
at com.novell.ldap.LDAPResponse.getResultException(Unknown Source)
at com.novell.ldap.LDAPResponse.chkResultCode(Unknown Source)
at com.novell.ldap.LDAPConnection.chkResultCode(Unknown Source)
at com.novell.ldap.LDAPConnection.add(Unknown Source)
at com.novell.ldap.LDAPConnection.add(Unknown Source)
at daten.vergleich.Vergleich.hinzu(Vergleich.java:383)
at daten.vergleich.Vergleich.ausfuehren(Vergleich.java:292)
at gui.Hauptfenster$27.actionPerformed(Hauptfenster.java:1731)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

bitte um eure hilfe!


----------



## SlaterB (7. Nov 2006)

falls noch nicht selber bei google gesehen, schaue dir mal das hier an:
http://forge.novell.com/pipermail/jldap-dev/2004-June/000139.html
(unten auf Next Message klicken)


----------



## RoliMG (7. Nov 2006)

ich bedanke mich sehr herzlich für den link!
werde morgen früh gleich den code dementsprechend ändern und testen.
bei erfolg poste ich die lösung natürlich.


----------



## RoliMG (8. Nov 2006)

hier die lösung des problems in einem programm:


```
LDAPConnection con = null;
		
try
{
	con = LUtil.getConnection();
}
catch (KonfiguartionsFehlerException e)
{
	// TODO Auto-generated catch block
	e.printStackTrace();
}
LDAPAttributeSet set = new LDAPAttributeSet();
		
set.add(new LDAPAttribute("givenName", "Franz"));
set.add(new LDAPAttribute("fullName", "Ferdinand"));
set.add(new LDAPAttribute("Language", "Deutsch"));
set.add(new LDAPAttribute("sn", "Hauns"));
set.add(new LDAPAttribute("passwordRequired", "TRUE"));
set.add(new LDAPAttribute("passwordMinimumLength", "5"));
set.add(new LDAPAttribute("passwordAllowChange", "TRUE"));
set.add(new LDAPAttribute("objectClass", "inetOrgPerson"));
set.add(new LDAPAttribute("objectClass", "organizationalPerson"));
set.add(new LDAPAttribute("objectClass", "person"));
set.add(new LDAPAttribute("objectClass", "top"));
set.add(new LDAPAttribute("objectClass", "ndsLoginProperties"));
set.add(new LDAPAttribute("loginScript", "rem"));
set.add(new LDAPAttribute("loginMaximumSimultaneous", "1"));
set.add(new LDAPAttribute("loginDisabled", "FALSE"));
set.add(new LDAPAttribute("uid", "5008"));
set.add(new LDAPAttribute("cn", "Franz F"));
set.add(new LDAPAttribute("userpassword", "passwort"));

LDAPEntry e = new LDAPEntry("cn=Franz,ou=person,o=dev", set);
		
try
{
	con.add(e);
}
catch (LDAPException e1)
{
	// TODO Auto-generated catch block
	e1.printStackTrace();
}
		
ArrayList modList = new ArrayList();
modList.add( new LDAPModification(LDAPModification.ADD, new LDAPAttribute("objectClass", "posixAccount")));
modList.add( new LDAPModification(LDAPModification.ADD, new LDAPAttribute("gidNumber", "100")));
modList.add( new LDAPModification(LDAPModification.ADD, new LDAPAttribute("homeDirectory", "/home/franz")));
modList.add( new LDAPModification(LDAPModification.ADD, new LDAPAttribute("uidNumber", "5008")));
modList.add( new LDAPModification(LDAPModification.ADD, new LDAPAttribute("loginShell", "/bin/sh")));

LDAPModification[] mod = new LDAPModification[modList.size()]; 
mod = (LDAPModification[])modList.toArray(mod);
        
try
{
	con.modify("cn=Franz,ou=person,o=dev", mod);
}
catch (LDAPException e1)
{
	// TODO Auto-generated catch block
	e1.printStackTrace();
}
```


----------

