Add entry error [LDAP: error code 65 - no objectClass attribute]; remaining name 'dc=srv,dc=world'

589 views
Skip to first unread message

baxu...@126.com

unread,
Apr 1, 2017, 5:12:36 AM4/1/17
to ldaptive



Apolog for my English.....I try to add a new entry to OpenLDAP server. The process of search is ok,but when add new entry,it return error.I have tried add process in LDAP Admin windows client,everything is ok.Thank you!
This is my code:
package ldaptive;


import java.util.Collection;


import org.ldaptive.AddOperation;
import org.ldaptive.AddRequest;
import org.ldaptive.BindOperation;
import org.ldaptive.BindRequest;
import org.ldaptive.Connection;
import org.ldaptive.Credential;
import org.ldaptive.DefaultConnectionFactory;
import org.ldaptive.LdapAttribute;
import org.ldaptive.LdapEntry;
import org.ldaptive.LdapException;
import org.ldaptive.SearchFilter;
import org.ldaptive.SearchOperation;
import org.ldaptive.SearchRequest;
import org.ldaptive.SearchResult;


public class LdapTiveTest {


 
public static void main(String[] args) throws LdapException {
 
Connection conn = DefaultConnectionFactory.getConnection("ldap://192.168.1.152");
 
try {
  conn
.open();
 
BindOperation bind = new BindOperation(conn);
  bind
.execute(new BindRequest("cn=Manager,dc=srv,dc=world", new Credential("c2VjcmV0")));
 
 
 
SearchOperation search = new SearchOperation(conn);
 
 
SearchFilter filter = new SearchFilter("(|(mail={mail}))");
  filter
.setParameter("mail", "baxu...@163.com");
 
 
 
 
SearchResult result = search.execute(
   
new SearchRequest(
     
"ou=People,dc=srv,dc=world",filter, "mail", "displayName", "userPassword")).getResult();
 
//result.getEntry(); // if you're expecting a single entry
 
for (LdapEntry entry : result.getEntries()) { // if you're expecting multiple entries
   
System.out.println(entry.getAttribute("displayName").getStringValue());
   
System.out.println(entry.getAttribute("userPassword").getStringValue());
 
}
 
 
LdapEntry addentry = new LdapEntry(
 
"dc=srv,dc=world",
 
new LdapAttribute("gidNumber", "0"),
 
new LdapAttribute("uid", "hehe"),
 
new LdapAttribute("cn", "hehe"),
 
new LdapAttribute("sn", "he"));
 
 
AddOperation add = new AddOperation(conn);
 
String adn = addentry.getDn();
 
Collection<LdapAttribute> aco = addentry.getAttributes();
 
  add
.execute(new AddRequest(adn,aco));
 
 
 
} finally {
  conn
.close();
 
}
 
}


}

And this is error message:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J
: Defaulting to no-operation (NOP) logger implementation
SLF4J
: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
baxuelong
MTIzNDU2
Exception in thread "main" [org.ldaptive.LdapException@204349222::resultCode=OBJECT_CLASS_VIOLATION, matchedDn=null, responseControls=null, referralURLs=null, messageId=-1, message=javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - no objectClass attribute]; remaining name 'dc=srv,dc=world', providerException=javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - no objectClass attribute]; remaining name 'dc=srv,dc=world']
 at org
.ldaptive.provider.ProviderUtils.throwOperationException(ProviderUtils.java:55)
 at org
.ldaptive.provider.jndi.JndiConnection.processNamingException(JndiConnection.java:619)
 at org
.ldaptive.provider.jndi.JndiConnection.add(JndiConnection.java:326)
 at org
.ldaptive.AddOperation.invoke(AddOperation.java:28)
 at org
.ldaptive.AddOperation.invoke(AddOperation.java:9)
 at org
.ldaptive.AbstractOperation.execute(AbstractOperation.java:126)
 at ldaptive
.LdapTiveTest.main(LdapTiveTest.java:57)
Caused by: javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - no objectClass attribute]; remaining name 'dc=srv,dc=world'
 at com
.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3166)
 at com
.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3081)
 at com
.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2888)
 at com
.sun.jndi.ldap.LdapCtx.c_createSubcontext(LdapCtx.java:812)
 at com
.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(ComponentDirContext.java:341)
 at com
.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(PartialCompositeDirContext.java:268)
 at org
.ldaptive.provider.jndi.JndiConnection.add(JndiConnection.java:315)
 
... 4 more

The below picture is ldap admin



Ben Howell-Thomas

unread,
Apr 3, 2017, 4:11:11 AM4/3/17
to ldap...@googlegroups.com
I'd guess the problem is :

Caused by: javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - no objectClass attribute]; remaining name 'dc=srv,dc=world'

Google will explain that for you, doesn't look like it's Ldaptive's fault.  Also :

  LdapEntry addentry = new LdapEntry(
  "dc=srv,dc=world",

Isn't that missing "ou=people"?

Ben

--
You received this message because you are subscribed to the Google Groups "ldaptive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ldaptive+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


This email is sent on behalf of Northgate Public Services (UK) Limited and its associated companies including Rave Technologies (India) Pvt Limited (together "Northgate Public Services") and is strictly confidential and intended solely for the addressee(s). 
If you are not the intended recipient of this email you must: (i) not disclose, copy or distribute its contents to any other person nor use its contents in any way or you may be acting unlawfully;  (ii) contact Northgate Public Services immediately on +44(0)1908 264500 quoting the name of the sender and the addressee then delete it from your system.
Northgate Public Services has taken reasonable precautions to ensure that no viruses are contained in this email, but does not accept any responsibility once this email has been transmitted.  You should scan attachments (if any) for viruses.

Northgate Public Services (UK) Limited, registered in England and Wales under number 00968498 with a registered address of Peoplebuilding 2, Peoplebuilding Estate, Maylands Avenue, Hemel Hempstead, Hertfordshire, HP2 4NN.  Rave Technologies (India) Pvt Limited, registered in India under number 117068 with a registered address of 2nd Floor, Ballard House, Adi Marzban Marg, Ballard Estate, Mumbai, Maharashtra, India, 400001.
Reply all
Reply to author
Forward
0 new messages