read.c
This is an example of doing a synchronous read operation, and how to process the returned results.
To compile this example on Unix:
cc -I /opt/isode/include -c read.c
To compile this example on Windows:
cl /nologo /I C:\Progra~1\Isode\include /c read.c
To link this example on Unix:
cc -o read read.o -L/opt/isode/lib \
-ldua -lisode -libase -lldap -llber \
-lisode_ssl -lisode_crypto -lpthread
To link this example on Windows:
cl /nologo /o read.exe read.obj \
C:\Progra~1\Isode\bin\libdua.lib
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdio.h>
00011
00012 #include <isode/ds/dsapi/dsapi.h>
00013
00023 int main ( void )
00024 {
00025 DS_Session *ds;
00026 DS_Indication *di;
00027 const DS_EntryList *el;
00028 const DS_Entry *e;
00029 const DS_AttrList *al;
00030 const DS_Attr *a;
00031 DS_DN *dn;
00032 const char *attrs[] = { "objectClass", "cn", "manager", NULL };
00033 DS_Status status;
00034
00035 status = DS_Initialize();
00036
00037 status = DS_String2DN( "cn=dsa,dc=example,dc=com", &dn );
00038
00039 status = DS_BindSync_Anonymous( "Internet=localhost+19999", &ds );
00040
00041 status = DS_ReadSync( ds, dn, attrs, NULL, &di );
00042
00043 status = DS_Indication_GetEntryList( di, &el );
00044
00045 e = DS_EntryList_GetFirst( el );
00046
00047 status = DS_Entry_GetAttrList( e, &al );
00048
00049 for ( a = DS_AttrList_GetFirst( al );
00050 a != NULL;
00051 a = DS_AttrList_GetNext( a ) ) {
00052
00053 const char *name;
00054 const DS_AttrValList *vl;
00055 const DS_AttrVal *v;
00056
00057 DS_Attr_GetTypeName( a, &name );
00058 printf( "%s:\n", name );
00059
00060
00061 status = DS_Attr_GetValueList( a, &vl );
00062
00063 for ( v = DS_AttrValList_GetFirst( vl );
00064 v != NULL;
00065 v = DS_AttrValList_GetNext( v ) ) {
00066
00067 const char *val_str;
00068 size_t val_len;
00069
00070 status = DS_AttrVal_GetStringPointer( v, &val_str, &val_len );
00071 if ( status == DS_E_NOERROR )
00072 printf( "\t%s\n", val_str );
00073 else
00074 printf( "\t(No string value)\n");
00075
00076
00077 }
00078 }
00079
00080 DS_Indication_Delete( di );
00081
00082 DS_UnbindSync( &ds );
00083 return 0;
00084 }