1 .\" Copyright (c) 2001-2005 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden).
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the Institute nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" $Heimdal: krb5_krbhst_init.3 15110 2005-05-10 09:21:06Z lha $
36 .Dt KRB5_KRBHST_INIT 3
39 .Nm krb5_krbhst_init ,
40 .Nm krb5_krbhst_init_flags ,
41 .Nm krb5_krbhst_next ,
42 .Nm krb5_krbhst_next_as_string ,
43 .Nm krb5_krbhst_reset ,
44 .Nm krb5_krbhst_free ,
45 .Nm krb5_krbhst_format_string ,
46 .Nm krb5_krbhst_get_addrinfo
47 .Nd lookup Kerberos KDC hosts
49 Kerberos 5 Library (libkrb5, -lkrb5)
53 .Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
55 .Fn krb5_krbhst_init_flags "krb5_context context" "const char *realm" "unsigned int type" "int flags" "krb5_krbhst_handle *handle"
57 .Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
59 .Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
61 .Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
63 .Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
65 .Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
67 .Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
69 These functions are used to sequence through all Kerberos hosts of a
70 particular realm and service. The service type can be the KDCs, the
71 administrative servers, the password changing servers, or the servers
72 for Kerberos 4 ticket conversion.
74 First a handle to a particular service is obtained by calling
77 .Fn krb5_krbhst_init_flags )
80 of interest and the type of service to lookup. The
84 .Bl -tag -width Ds -compact -offset indent
87 .It KRB5_KRBHST_CHANGEPW
88 .It KRB5_KRBHST_KRB524
93 is returned to the caller, and should be passed to the other
99 .Nm krb5_krbhst_init_flags
101 .Fn krb5_send_to_kdc_flags
105 .Bl -tag -width KRB5_KRBHST_FLAGS_LARGE_MSG -compact -offset indent
106 .It KRB5_KRBHST_FLAGS_MASTER
107 only talk to master (readwrite) KDC
108 .It KRB5_KRBHST_FLAGS_LARGE_MSG
109 this is a large message, so use transport that can handle that.
114 information on a new host is returned. The former function returns in
116 a pointer to a structure containing information about the host, such
117 as protocol, hostname, and port:
118 .Bd -literal -offset indent
119 typedef struct krb5_krbhst_info {
120 enum { KRB5_KRBHST_UDP,
122 KRB5_KRBHST_HTTP } proto;
125 struct krb5_krbhst_info *next;
130 The related function,
131 .Fn krb5_krbhst_next_as_string ,
132 return the same information as a URL-like string.
134 When there are no more hosts, these functions return
135 .Dv KRB5_KDC_UNREACH .
137 To re-iterate over all hosts, call
138 .Fn krb5_krbhst_reset
141 will return the first host.
143 When done with the handle,
148 .Va krb5_krbhst_info ,
149 there are two functions:
150 .Fn krb5_krbhst_format_string
151 that will return a printable representation of that struct
153 .Fn krb5_krbhst_get_addrinfo
156 that can then be used for communicating with the server mentioned.
158 The following code will print the KDCs of the realm
160 .Bd -literal -offset indent
161 krb5_krbhst_handle handle;
162 char host[MAXHOSTNAMELEN];
163 krb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
164 while(krb5_krbhst_next_as_string(context, handle,
165 host, sizeof(host)) == 0)
166 printf("%s\\n", host);
167 krb5_krbhst_free(context, handle);
172 .Xr krb5_get_krbhst 3 ,
173 .Xr krb5_send_to_kdc_flags 3
175 These functions first appeared in Heimdal 0.3g.