simple.c

This is an example of doing a simple bind, that is, a bind with a DN and a password.

To compile this example on Unix:

  cc -I /opt/isode/include -c simple.c 
  

To compile this example on Windows:

  cl /nologo /I C:\Progra~1\Isode\include /c simple.c
  

To link this example on Unix:

  cc -o simple simple.o -L/opt/isode/lib \
      -ldua -lisode -libase -lldap -llber \
      -lisode_ssl -lisode_crypto -lpthread
  

To link this example on Windows:

  cl /nologo /o simple.exe simple.obj \
      C:\Progra~1\Isode\bin\libdua.lib
  

00001 /* 
00002  * Copyright (c) 2005-2006, Isode Limited, London, England.
00003  * All rights reserved.
00004  * 
00005  * Acquisition and use of this software and related materials for any
00006  * purpose requires a written licence agreement from Isode Limited,
00007  * or a written licence from an organisation licenced by Isode Limited
00008  * to grant such a licence.
00009  */
00010 #include <stdio.h>
00011 
00012 #include <isode/ds/dsapi/dsapi.h>
00013 
00022 int main ( void )
00023 {
00024     DS_Session *ds;
00025     DS_DN      *dn;
00026     DS_Status   status;
00027 
00028     status = DS_Initialize( );
00029     if ( status != DS_E_NOERROR ) {
00030         fprintf( stderr, "Initialization failed\n" );
00031         return 1;
00032     }
00033 
00034     status = DS_String2DN( "cn=DSA Manager,cn=dsa,dc=example,dc=com", &dn );
00035     if ( status != DS_E_NOERROR ) {
00036         fprintf( stderr, "Bad DN\n" );
00037         return 1;
00038     }
00039     
00040     status = DS_BindSync_Simple( "Internet=localhost+19999",
00041                                  dn, "secret",
00042                                  &ds );
00043     DS_DN_Delete( dn );
00044 
00045     if ( status != DS_E_NOERROR ) {
00046         fprintf( stderr, "Bind failed\n" );
00047         return 1;
00048     }
00049     DS_UnbindSync( &ds );
00050     return 0;
00051 }
Copyright © 2008 Isode privacy   feedback Subscribe to our rss newsfeed