anonymous.c

This is an example of doing an anonymous bind.

To compile this example on Unix:

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

To compile this example on Windows:

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

To link this example on Unix:

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

To link this example on Windows:

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

00001 /* 
00002  * Copyright (c) 2005-2009, 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 = NULL;
00025     DS_Indication *di = NULL;
00026     DS_Status   status;
00027     DS_ErrorType   t;
00028     DS_ErrorValue  v;
00029 
00030     status = DS_Initialize( );
00031     if ( status != DS_E_NOERROR ) {
00032         fprintf( stderr, "Initialization failed\n" );
00033         return 1;
00034     }
00035     
00036     status = DS_Session_New( "Internet=localhost+19999", 0, &ds );
00037     if ( status != DS_E_NOERROR ) {
00038         fprintf( stderr, "Failed to create session\n" );
00039         return 1;
00040     }
00041 
00042     status = DS_BindAnonymousSync( ds, NULL, &di );
00043 
00044     if ( DS_Indication_GetErrorCodes( di, &t, &v ) == DS_E_NOERROR &&
00045          t != DS_E_SUCCESS )
00046         status = DS_E_DSOPFAILED;
00047 
00048     DS_Indication_Delete( di );
00049 
00050     if ( status != DS_E_NOERROR) {
00051         DS_UnbindSync( &ds );
00052         fprintf( stderr, "Failed to bind\n" );
00053         return 1;
00054     }
00055 
00056     
00057     DS_UnbindSync( &ds );
00058     return 0;
00059 }
Copyright © 2010 Isode privacy   feedback Subscribe to our rss newsfeed