1 .\" Copyright (c) 2001 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 .\" $Id: krb5_krbhst_init.3,v 1.7 2003/04/16 13:58:16 lha Exp $
35 .Dt KRB5_KRBHST_INIT 3
38 .Nm krb5_krbhst_init ,
39 .Nm krb5_krbhst_next ,
40 .Nm krb5_krbhst_next_as_string ,
41 .Nm krb5_krbhst_reset ,
42 .Nm krb5_krbhst_free ,
43 .Nm krb5_krbhst_format_string ,
44 .Nm krb5_krbhst_get_addrinfo
45 .Nd lookup Kerberos KDC hosts
47 Kerberos 5 Library (libkrb5, -lkrb5)
51 .Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
53 .Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
55 .Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
57 .Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
59 .Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
61 .Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
63 .Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
65 These functions are used to sequence through all Kerberos hosts of a
66 particular realm and service. The service type can be the KDCs, the
67 administrative servers, the password changing servers, or the servers
68 for Kerberos 4 ticket conversion.
70 First a handle to a particular service is obtained by calling
74 of interest and the type of service to lookup. The
78 .Bl -hang -compact -offset indent
81 .It KRB5_KRBHST_CHANGEPW
82 .It KRB5_KRBHST_KRB524
87 is returned to the caller, and should be passed to the other
92 information a new host is returned. The former function returns in
94 a pointer to a structure containing information about the host, such
95 as protocol, hostname, and port:
96 .Bd -literal -offset indent
97 typedef struct krb5_krbhst_info {
98 enum { KRB5_KRBHST_UDP,
100 KRB5_KRBHST_HTTP } proto;
103 struct krb5_krbhst_info *next;
108 The related function,
109 .Fn krb5_krbhst_next_as_string ,
110 return the same information as a url-like string.
112 When there are no more hosts, these functions return
113 .Dv KRB5_KDC_UNREACH .
115 To re-iterate over all hosts, call
116 .Fn krb5_krbhst_reset
119 will return the first host.
121 When done with the handle,
126 .Va krb5_krbhst_info ,
127 there are two functions:
128 .Fn krb5_krbhst_format_string
129 that will return a printable representation of that struct
131 .Fn krb5_krbhst_get_addrinfo
134 that can then be used for communicating with the server mentioned.
136 The following code will print the KDCs of the realm
138 .Bd -literal -offset indent
139 krb5_krbhst_handle handle;
140 char host[MAXHOSTNAMELEN];
141 krb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
142 while(krb5_krbhst_next_as_string(context, handle,
143 host, sizeof(host)) == 0)
144 printf("%s\\n", host);
145 krb5_krbhst_free(context, handle);
149 These functions first appeared in Heimdal 0.3g.
152 .Xr krb5_get_krbhst 3