1 .\" $NetBSD: krb5_krbhst_init.3,v 1.1.1.2 2011/04/14 14:09:23 elric Exp $
3 .\" Copyright (c) 2001-2005 Kungliga Tekniska Högskolan
4 .\" (Royal Institute of Technology, Stockholm, Sweden).
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the Institute nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 .Dt KRB5_KRBHST_INIT 3
40 .Nm krb5_krbhst_init ,
41 .Nm krb5_krbhst_init_flags ,
42 .Nm krb5_krbhst_next ,
43 .Nm krb5_krbhst_next_as_string ,
44 .Nm krb5_krbhst_reset ,
45 .Nm krb5_krbhst_free ,
46 .Nm krb5_krbhst_format_string ,
47 .Nm krb5_krbhst_get_addrinfo
48 .Nd lookup Kerberos KDC hosts
50 Kerberos 5 Library (libkrb5, -lkrb5)
54 .Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
56 .Fn krb5_krbhst_init_flags "krb5_context context" "const char *realm" "unsigned int type" "int flags" "krb5_krbhst_handle *handle"
58 .Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
60 .Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
62 .Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
64 .Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
66 .Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
68 .Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
70 These functions are used to sequence through all Kerberos hosts of a
71 particular realm and service. The service type can be the KDCs, the
72 administrative servers, the password changing servers, or the servers
73 for Kerberos 4 ticket conversion.
75 First a handle to a particular service is obtained by calling
78 .Fn krb5_krbhst_init_flags )
81 of interest and the type of service to lookup. The
85 .Bl -tag -width Ds -compact -offset indent
88 .It KRB5_KRBHST_CHANGEPW
89 .It KRB5_KRBHST_KRB524
94 is returned to the caller, and should be passed to the other
100 .Nm krb5_krbhst_init_flags
102 .Fn krb5_send_to_kdc_flags
106 .Bl -tag -width KRB5_KRBHST_FLAGS_LARGE_MSG -compact -offset indent
107 .It KRB5_KRBHST_FLAGS_MASTER
108 only talk to master (readwrite) KDC
109 .It KRB5_KRBHST_FLAGS_LARGE_MSG
110 this is a large message, so use transport that can handle that.
115 information on a new host is returned. The former function returns in
117 a pointer to a structure containing information about the host, such
118 as protocol, hostname, and port:
119 .Bd -literal -offset indent
120 typedef struct krb5_krbhst_info {
121 enum { KRB5_KRBHST_UDP,
123 KRB5_KRBHST_HTTP } proto;
126 struct krb5_krbhst_info *next;
131 The related function,
132 .Fn krb5_krbhst_next_as_string ,
133 return the same information as a URL-like string.
135 When there are no more hosts, these functions return
136 .Dv KRB5_KDC_UNREACH .
138 To re-iterate over all hosts, call
139 .Fn krb5_krbhst_reset
142 will return the first host.
144 When done with the handle,
149 .Va krb5_krbhst_info ,
150 there are two functions:
151 .Fn krb5_krbhst_format_string
152 that will return a printable representation of that struct
154 .Fn krb5_krbhst_get_addrinfo
157 that can then be used for communicating with the server mentioned.
159 The following code will print the KDCs of the realm
161 .Bd -literal -offset indent
162 krb5_krbhst_handle handle;
163 char host[MAXHOSTNAMELEN];
164 krb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
165 while(krb5_krbhst_next_as_string(context, handle,
166 host, sizeof(host)) == 0)
167 printf("%s\\n", host);
168 krb5_krbhst_free(context, handle);
173 .Xr krb5_get_krbhst 3 ,
174 .Xr krb5_send_to_kdc_flags 3
176 These functions first appeared in Heimdal 0.3g.