2 * Copyright (c) 1992, 1994 Regents of the University of Michigan.
9 static char copyright[] = "@(#) Copyright (c) 1994 Regents of the University of Michigan.\nAll rights reserved.\n";
26 #include <MixedMode.h>
28 #include "authLibrary.h"
32 * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap.
37 get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len )
39 static short authman_refnum = 0;
40 char *cred, ticket[ MAX_KTXT_LEN ];
41 short version, ticketlen, err;
45 * make sure RJC's Authentication Manager 2.0 or better is available
47 if ( authman_refnum == 0 && (( err = openAuthMan( &authman_refnum, &version )) != noErr || version < 2 )) {
49 ld->ld_errno = LDAP_AUTH_UNKNOWN;
53 strcpy( (char *)svcps, service );
54 CtoPstr( (char *)svcps );
56 strcpy( (char *)instps, ld->ld_defconn->lconn_krbinstance );
57 #else /* LDAP_REFERRALS */
58 strcpy( (char *)instps, ld->ld_host );
59 #endif /* LDAP_REFERRALS */
61 CtoPstr( (char *)instps );
62 if (( err = getV4Ticket( authman_refnum, &ticket, &ticketlen, &svcps, &instps,
63 NULL, INFINITE_LIFETIME, 1 )) != noErr ) {
64 ld->ld_errno = ( err == userCanceledErr ) ?
65 LDAP_USER_CANCELLED : LDAP_INVALID_CREDENTIALS;
69 if (( cred = malloc( ticketlen )) == NULL ) {
70 ld->ld_errno = LDAP_NO_MEMORY;
75 memcpy( cred, (char *)ticket, ticketlen );