get_c.c revision 178825
121217Swollman/* 22742Swollman * Copyright (c) 1997 - 2000, 2006 Kungliga Tekniska H�gskolan 32742Swollman * (Royal Institute of Technology, Stockholm, Sweden). 42742Swollman * All rights reserved. 52742Swollman * 62742Swollman * Redistribution and use in source and binary forms, with or without 720094Swollman * modification, are permitted provided that the following conditions 82742Swollman * are met: 92742Swollman * 102742Swollman * 1. Redistributions of source code must retain the above copyright 112742Swollman * notice, this list of conditions and the following disclaimer. 122742Swollman * 132742Swollman * 2. Redistributions in binary form must reproduce the above copyright 1420094Swollman * notice, this list of conditions and the following disclaimer in the 1520094Swollman * documentation and/or other materials provided with the distribution. 1620094Swollman * 1720094Swollman * 3. Neither the name of the Institute nor the names of its contributors 1820094Swollman * may be used to endorse or promote products derived from this software 1920094Swollman * without specific prior written permission. 2020094Swollman * 2120094Swollman * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2220094Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 232742Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 242742Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 252742Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 262742Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 272742Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 282742Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 292742Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 302742Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 312742Swollman * SUCH DAMAGE. 322742Swollman */ 332742Swollman 342742Swollman#include "kadm5_locl.h" 352742Swollman 3619878SwollmanRCSID("$Id: get_c.c 17445 2006-05-05 10:37:46Z lha $"); 372742Swollman 382742Swollmankadm5_ret_t 3919878Swollmankadm5_c_get_principal(void *server_handle, 4019878Swollman krb5_principal princ, 412742Swollman kadm5_principal_ent_t out, 4219878Swollman uint32_t mask) 4319878Swollman{ 4419878Swollman kadm5_client_context *context = server_handle; 4519878Swollman kadm5_ret_t ret; 462742Swollman krb5_storage *sp; 479908Swollman unsigned char buf[1024]; 482742Swollman int32_t tmp; 4919878Swollman krb5_data reply; 502742Swollman 512742Swollman ret = _kadm5_connect(server_handle); 522742Swollman if(ret) 532742Swollman return ret; 542742Swollman 552742Swollman sp = krb5_storage_from_mem(buf, sizeof(buf)); 562742Swollman if (sp == NULL) { 572742Swollman krb5_clear_error_string(context->context); 582742Swollman return ENOMEM; 5920094Swollman } 602742Swollman krb5_store_int32(sp, kadm_get); 6120094Swollman krb5_store_principal(sp, princ); 6220094Swollman krb5_store_int32(sp, mask); 6320094Swollman ret = _kadm5_client_send(context, sp); 6420094Swollman krb5_storage_free(sp); 6520094Swollman if(ret) 6620094Swollman return ret; 6720094Swollman ret = _kadm5_client_recv(context, &reply); 6820094Swollman if (ret) 6920094Swollman return ret; 7020094Swollman sp = krb5_storage_from_data (&reply); 7120094Swollman if (sp == NULL) { 7220094Swollman krb5_clear_error_string(context->context); 7320094Swollman krb5_data_free (&reply); 7420094Swollman return ENOMEM; 752742Swollman } 762742Swollman krb5_ret_int32(sp, &tmp); 772742Swollman ret = tmp; 782742Swollman krb5_clear_error_string(context->context); 7919878Swollman if(ret == 0) 802742Swollman kadm5_ret_principal_ent(sp, out); 812742Swollman krb5_storage_free(sp); 822742Swollman krb5_data_free (&reply); 8317200Swollman return ret; 8417200Swollman} 8517200Swollman