]> git.sur5r.net Git - openldap/commitdiff
Moved sample code to examples dir
authorRalf Haferkamp <ralf@openldap.org>
Thu, 5 Jun 2003 18:10:44 +0000 (18:10 +0000)
committerRalf Haferkamp <ralf@openldap.org>
Thu, 5 Jun 2003 18:10:44 +0000 (18:10 +0000)
contrib/ldapc++/Makefile.am
contrib/ldapc++/configure.in
contrib/ldapc++/examples/Makefile.am [new file with mode: 0644]
contrib/ldapc++/examples/main.cpp [new file with mode: 0644]
contrib/ldapc++/src/Makefile.am
contrib/ldapc++/src/main.cpp [deleted file]

index d042552ff70517285f6951f26984731fb489dab1..85c1b008fd921e6efd80ff6e4a4dd19cdead51ea 100644 (file)
@@ -1,8 +1,8 @@
 ##
-# Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
+# Copyright 2000-2003, OpenLDAP Foundation, All Rights Reserved.
 # COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
 
 EXTRA_DIST = BUGS
-SUBDIRS = src 
+SUBDIRS = src examples
 
index a622bf759e620333eb713be7c47c96329a06df89..f303f743b551bca989ed616324c74ddfaa49cad2 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
+dnl Copyright 2000-2003, OpenLDAP Foundation, All Rights Reserved.
 dnl COPYING RESTRICTIONS APPLY, see COPYRIGHT file
   
   
@@ -8,7 +8,7 @@ dnl disable config.cache
 dnl define([AC_CACHE_LOAD], )
 dnl define([AC_CACHE_SAVE], )
 
-AC_INIT(src/main.cpp)
+AC_INIT(examples/main.cpp)
 AM_INIT_AUTOMAKE(main, 0.0.1)
 AM_CONFIG_HEADER(src/config.h)
 
@@ -91,4 +91,4 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 
 dnl Checks for library functions.
 
-AC_OUTPUT(Makefile src/Makefile)
+AC_OUTPUT(Makefile src/Makefile examples/Makefile)
diff --git a/contrib/ldapc++/examples/Makefile.am b/contrib/ldapc++/examples/Makefile.am
new file mode 100644 (file)
index 0000000..3e3a6b8
--- /dev/null
@@ -0,0 +1,8 @@
+##
+# Copyright 2003, OpenLDAP Foundation, All Rights Reserved.
+# COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+##
+noinst_PROGRAMS = main
+
+main_SOURCES = main.cpp
+main_LDADD = ../src/libldapcpp.la
diff --git a/contrib/ldapc++/examples/main.cpp b/contrib/ldapc++/examples/main.cpp
new file mode 100644 (file)
index 0000000..8fff4d4
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include<iostream.h>
+#include<strstream>
+#include "LDAPConnection.h"
+#include "LDAPConstraints.h"
+#include "LDAPSearchReference.h"
+#include "LDAPSearchResults.h"
+#include "LDAPAttribute.h"
+#include "LDAPAttributeList.h"
+#include "LDAPEntry.h"
+#include "LDAPException.h"
+#include "LDAPModification.h"
+#include "LDAPReferralException.h"
+
+#include"debug.h"
+
+int main(){
+    LDAPConstraints* cons=new LDAPConstraints;
+    LDAPControlSet* ctrls=new LDAPControlSet;
+    ctrls->add(LDAPCtrl(LDAP_CONTROL_MANAGEDSAIT));
+    cons->setServerControls(ctrls);
+    LDAPConnection *lc=new LDAPConnection("localhost",9009);
+    lc->setConstraints(cons);
+    cout << "----------------------doing bind...." <<  endl;
+    try{
+        lc->bind("cn=Manager,o=Organisation,c=DE" , "secret",cons);
+        cout << lc->getHost() << endl;    
+        bool result = lc->compare("cn=Manager,o=Organisation,c=DE", 
+                LDAPAttribute("cn","Manaer"));
+        cout << "Compare: " << result << endl;
+    
+        LDAPAttributeList* attrs=new LDAPAttributeList();
+        StringList values;
+        StringList s2;
+        values.add("top");
+        values.add("Person");
+        attrs->addAttribute(LDAPAttribute("objectClass",values));
+        attrs->addAttribute(LDAPAttribute("cn","Peter"));
+        attrs->addAttribute(LDAPAttribute("sn","Peter,hallo"));
+        LDAPEntry* entry=new LDAPEntry(
+                "cn=Peter , o=Organisation, c=DE", attrs);    
+//        lc->add(entry);
+        
+//        lc->del("ou=Groups,o=Organisation,c=DE");
+
+        LDAPSearchResults* entries = lc->search("o=Organisation,c=DE",
+                LDAPConnection::SEARCH_ONE);
+        if (entries != 0){
+            LDAPEntry* entry = entries->getNext();
+            if(entry != 0){
+                cout << *(entry) << endl;
+            }
+            while(entry){
+                try{
+                    entry = entries->getNext();
+                    if(entry != 0){
+                        cout << *(entry) << endl;
+                    }
+                    delete entry;
+                }catch(LDAPReferralException e){
+                    cout << "Caught Referral" << endl;
+                }
+            }
+        }
+        
+        lc->unbind();
+        delete lc;
+   }catch (LDAPException e){
+        cout << "------------------------- caught Exception ---------"<< endl;
+        cout << e << endl;
+    }
+
+    /*
+    cout << "--------------------starting search" << endl;
+    LDAPAttributeList* attrs=new LDAPAttributeList();
+    StringList values;
+    values.add("top");
+    values.add("organizationalUnit");
+    attrs->addAttribute(LDAPAttribute("objectClass",values));
+    attrs->addAttribute(LDAPAttribute("ou","Groups"));
+    LDAPEntry* entry=new LDAPEntry(
+            "ou=Groups, o=Organisation, c=DE", attrs);    
+
+    LDAPAttribute newattr("description");
+    LDAPModification::mod_op op = LDAPModification::OP_DELETE;
+    LDAPModList *mod=new LDAPModList();
+    mod->addModification(LDAPModification(newattr,op));
+    LDAPMessageQueue* q=0;
+    try{
+        q=lc->search("o=Organisation,c=de",LDAPAsynConnection::SEARCH_SUB,
+         "objectClass=*",StringList());
+//        q=lc->add(entry);
+//        q=lc->modify("cn=Manager,o=Organisation,c=DE",
+//                mod);
+        LDAPMsg *res=q->getNext();
+        bool cont=true;
+        while( cont  ) {
+            switch(res->getMessageType()){
+                LDAPSearchResult *res2;
+                const LDAPEntry *entry;
+                case LDAP_RES_SEARCH_ENTRY :
+                    res2= (LDAPSearchResult*)res;
+                    entry=  res2->getEntry();
+                    cout << "Entry:            " << *entry << endl; 
+                    delete res;
+                    res=q->getNext();
+                break;
+                case LDAP_RES_SEARCH_REFERENCE :
+                    cout << "Reference:         "  << endl;
+                    delete res;
+                    res=q->getNext();
+                break;
+                default :
+                    cout << ( *(LDAPResult*) res) << endl;
+                    delete res;
+                    cout  << "-----------------search done" << endl;
+                    cont=false;
+                break;
+            }
+        }
+        delete q;
+    }catch (LDAPException e){
+        cout << "----------------error during search" << endl;
+        delete q;
+        cout << e << endl;
+    }
+    lc->unbind();
+    */
+}
+
index d9e85faa3abad392d211c37077f60c7ed2cf6434..20a594b27c806004832fc494b4774edbe8f12c91 100644 (file)
@@ -80,10 +80,4 @@ noinst_HEADERS = LDAPAddRequest.h \
 
 libldapcpp_la_LIBADD = -lldap -llber
 libldapcpp_la_LDFLAGS = -version-info 0:1:0
-                       
-noinst_PROGRAMS = main
-
-main_SOURCES = main.cpp
-main_LDADD = ./libldapcpp.la 
-
 
diff --git a/contrib/ldapc++/src/main.cpp b/contrib/ldapc++/src/main.cpp
deleted file mode 100644 (file)
index 8fff4d4..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-#include<iostream.h>
-#include<strstream>
-#include "LDAPConnection.h"
-#include "LDAPConstraints.h"
-#include "LDAPSearchReference.h"
-#include "LDAPSearchResults.h"
-#include "LDAPAttribute.h"
-#include "LDAPAttributeList.h"
-#include "LDAPEntry.h"
-#include "LDAPException.h"
-#include "LDAPModification.h"
-#include "LDAPReferralException.h"
-
-#include"debug.h"
-
-int main(){
-    LDAPConstraints* cons=new LDAPConstraints;
-    LDAPControlSet* ctrls=new LDAPControlSet;
-    ctrls->add(LDAPCtrl(LDAP_CONTROL_MANAGEDSAIT));
-    cons->setServerControls(ctrls);
-    LDAPConnection *lc=new LDAPConnection("localhost",9009);
-    lc->setConstraints(cons);
-    cout << "----------------------doing bind...." <<  endl;
-    try{
-        lc->bind("cn=Manager,o=Organisation,c=DE" , "secret",cons);
-        cout << lc->getHost() << endl;    
-        bool result = lc->compare("cn=Manager,o=Organisation,c=DE", 
-                LDAPAttribute("cn","Manaer"));
-        cout << "Compare: " << result << endl;
-    
-        LDAPAttributeList* attrs=new LDAPAttributeList();
-        StringList values;
-        StringList s2;
-        values.add("top");
-        values.add("Person");
-        attrs->addAttribute(LDAPAttribute("objectClass",values));
-        attrs->addAttribute(LDAPAttribute("cn","Peter"));
-        attrs->addAttribute(LDAPAttribute("sn","Peter,hallo"));
-        LDAPEntry* entry=new LDAPEntry(
-                "cn=Peter , o=Organisation, c=DE", attrs);    
-//        lc->add(entry);
-        
-//        lc->del("ou=Groups,o=Organisation,c=DE");
-
-        LDAPSearchResults* entries = lc->search("o=Organisation,c=DE",
-                LDAPConnection::SEARCH_ONE);
-        if (entries != 0){
-            LDAPEntry* entry = entries->getNext();
-            if(entry != 0){
-                cout << *(entry) << endl;
-            }
-            while(entry){
-                try{
-                    entry = entries->getNext();
-                    if(entry != 0){
-                        cout << *(entry) << endl;
-                    }
-                    delete entry;
-                }catch(LDAPReferralException e){
-                    cout << "Caught Referral" << endl;
-                }
-            }
-        }
-        
-        lc->unbind();
-        delete lc;
-   }catch (LDAPException e){
-        cout << "------------------------- caught Exception ---------"<< endl;
-        cout << e << endl;
-    }
-
-    /*
-    cout << "--------------------starting search" << endl;
-    LDAPAttributeList* attrs=new LDAPAttributeList();
-    StringList values;
-    values.add("top");
-    values.add("organizationalUnit");
-    attrs->addAttribute(LDAPAttribute("objectClass",values));
-    attrs->addAttribute(LDAPAttribute("ou","Groups"));
-    LDAPEntry* entry=new LDAPEntry(
-            "ou=Groups, o=Organisation, c=DE", attrs);    
-
-    LDAPAttribute newattr("description");
-    LDAPModification::mod_op op = LDAPModification::OP_DELETE;
-    LDAPModList *mod=new LDAPModList();
-    mod->addModification(LDAPModification(newattr,op));
-    LDAPMessageQueue* q=0;
-    try{
-        q=lc->search("o=Organisation,c=de",LDAPAsynConnection::SEARCH_SUB,
-         "objectClass=*",StringList());
-//        q=lc->add(entry);
-//        q=lc->modify("cn=Manager,o=Organisation,c=DE",
-//                mod);
-        LDAPMsg *res=q->getNext();
-        bool cont=true;
-        while( cont  ) {
-            switch(res->getMessageType()){
-                LDAPSearchResult *res2;
-                const LDAPEntry *entry;
-                case LDAP_RES_SEARCH_ENTRY :
-                    res2= (LDAPSearchResult*)res;
-                    entry=  res2->getEntry();
-                    cout << "Entry:            " << *entry << endl; 
-                    delete res;
-                    res=q->getNext();
-                break;
-                case LDAP_RES_SEARCH_REFERENCE :
-                    cout << "Reference:         "  << endl;
-                    delete res;
-                    res=q->getNext();
-                break;
-                default :
-                    cout << ( *(LDAPResult*) res) << endl;
-                    delete res;
-                    cout  << "-----------------search done" << endl;
-                    cont=false;
-                break;
-            }
-        }
-        delete q;
-    }catch (LDAPException e){
-        cout << "----------------error during search" << endl;
-        delete q;
-        cout << e << endl;
-    }
-    lc->unbind();
-    */
-}
-