2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2004 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This program was orignally developed by Kurt D. Zeilenga for inclusion in
22 #include <ac/stdlib.h>
25 #include <ac/string.h>
29 #ifdef LDAP_EXOP_GROUPING_CREATE
31 int ldap_grouping_create(
33 LDAP_CONST char *grpoid,
34 struct berval *grpdata,
40 BerElement *ber = NULL;
41 struct berval bv = BER_BVNULL;
43 Debug( LDAP_DEBUG_TRACE, "ldap_grouping_create\n", 0, 0, 0 );
46 assert( LDAP_VALID( ld ) );
47 assert( grpoid != NULL || *grpoid == '\0' );
48 assert( msgidp != NULL );
50 /* build the create grouping exop */
51 ber = ber_alloc_t( LBER_USE_DER );
53 ld->ld_errno = LDAP_NO_MEMORY;
54 return( ld->ld_errno );
57 if ( grpdata != NULL ) {
58 ber_printf( ber, "{sON}", grpoid, grpdata );
60 ber_printf( ber, "{sN}", grpoid );
63 rc = ber_flatten2( ber, &bv, 0 );
65 ld->ld_errno = LDAP_ENCODING_ERROR;
66 return( ld->ld_errno );
69 rc = ldap_extended_operation( ld, LDAP_EXOP_GROUPING_CREATE,
70 &bv, sctrls, cctrls, msgidp );
76 int ldap_grouping_create_s(
78 LDAP_CONST char *grpoid,
79 struct berval *grpdata,
82 struct berval **retgrpcookiep,
83 struct berval **retgrpdatap )
89 Debug( LDAP_DEBUG_TRACE, "ldap_grouping_create_s\n", 0, 0, 0 );
92 assert( LDAP_VALID( ld ) );
93 assert( grpoid != NULL || *grpoid == '\0' );
95 rc = ldap_grouping_create( ld, grpoid, grpdata,
96 sctrls, cctrls, &msgid );
97 if ( rc != LDAP_SUCCESS ) {
101 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) {
105 if ( retgrpcookiep != NULL ) *retgrpcookiep = NULL;
106 if ( retgrpdatap != NULL ) *retgrpdatap = NULL;
109 rc = ldap_parse_extended_result( ld, res, retoidp, retdatap, 0 );
111 rc = LDAP_NOT_SUPPORTED;
114 if( rc != LDAP_SUCCESS ) {
119 return( ldap_result2error( ld, res, 1 ) );
122 int ldap_grouping_end(
124 LDAP_CONST char *grpoid,
125 struct berval *grpdata,
126 LDAPControl **sctrls,
127 LDAPControl **cctrls,
132 int ldap_grouping_end_s(
134 LDAP_CONST char *grpoid,
135 struct berval *grpdata,
136 LDAPControl **sctrls,
137 LDAPControl **cctrls,
138 struct berval **retgrpdatap )