3 * Copyright 2008-2011 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 #include "LDAPConnection.h"
10 #include "LDAPConstraints.h"
11 #include "LDAPSearchReference.h"
12 #include "LDAPSearchResults.h"
13 #include "LDAPAttribute.h"
14 #include "LDAPAttributeList.h"
15 #include "LDAPEntry.h"
16 #include "LDAPException.h"
17 #include "LDAPModification.h"
18 #include "LDAPSchema.h"
23 LDAPConnection *lc=new LDAPConnection("192.168.3.128",389);
24 std::cout << "----------------------doing bind...." << std::endl;
26 lc->bind("uid=admin,dc=home,dc=local" , "secret");
27 std::cout << lc->getHost() << std::endl;
29 tmp.add("subschemasubentry");
30 LDAPSearchResults* entries = lc->search("",
31 LDAPConnection::SEARCH_BASE,
34 LDAPEntry* rootDse = entries->getNext();
35 std::string schemabase="cn=subschema";
38 const LDAPAttribute* schemaAttr = rootDse->getAttributes()->getAttributeByName("subschemaSubentry");
39 schemabase = *(schemaAttr->getValues().begin());
42 attrs.add("objectClasses");
43 attrs.add("attributeTypes");
44 entries = lc->search(schemabase, LDAPConnection::SEARCH_BASE, "(objectClass=*)",
47 LDAPEntry* entry = entries->getNext();
49 const LDAPAttribute* oc = entry->getAttributes()->getAttributeByName("objectClasses");
51 schema.setObjectClasses((oc->getValues()));
52 LDAPObjClass test = schema.getObjectClassByName("inetOrgPerson");
53 std::cout << test.getDesc() << std::endl;
54 // StringList mustAttr = test.getMay();
55 // for( StringList::const_iterator i = mustAttr.begin(); i != mustAttr.end(); i++ ){
56 // std::cout << *i << std::endl;
58 StringList sup = test.getSup();
59 for( StringList::const_iterator i = sup.begin(); i != sup.end(); i++ ){
60 std::cout << *i << std::endl;
67 }catch (LDAPException e){
68 std::cout << "---------------- caught Exception ---------"<< std::endl;
69 std::cout << e << std::endl;