1 .\" Copyright (c) 2001 Kungliga Tekniska Högskolan
2 .\" $Id: krb5_krbhst_init.3,v 1.5 2002/08/28 15:30:54 joda Exp $
9 .Nm krb5_krbhst_next_as_string ,
10 .Nm krb5_krbhst_reset ,
11 .Nm krb5_krbhst_free ,
12 .Nm krb5_krbhst_format_string ,
13 .Nm krb5_krbhst_get_addrinfo
14 .Nd lookup Kerberos KDC hosts
16 Kerberos 5 Library (libkrb5, -lkrb5)
20 .Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
22 .Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
24 .Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
26 .Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
28 .Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
30 .Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
32 .Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
34 These functions are used to sequence through all Kerberos hosts of a
35 particular realm and service. The service type can be the KDCs, the
36 administrative servers, the password changing servers, or the servers
37 for Kerberos 4 ticket conversion.
39 First a handle to a particular service is obtained by calling
43 of interest and the type of service to lookup. The
47 .Bl -hang -compact -offset indent
50 .It KRB5_KRBHST_CHANGEPW
51 .It KRB5_KRBHST_KRB524
56 is returned to the caller, and should be passed to the other
61 information a new host is returned. The former function returns in
63 a pointer to a structure containing information about the host, such
64 as protocol, hostname, and port:
65 .Bd -literal -offset indent
66 typedef struct krb5_krbhst_info {
67 enum { KRB5_KRBHST_UDP,
69 KRB5_KRBHST_HTTP } proto;
72 struct krb5_krbhst_info *next;
78 .Fn krb5_krbhst_next_as_string ,
79 return the same information as a url-like string.
81 When there are no more hosts, these functions return
82 .Dv KRB5_KDC_UNREACH .
84 To re-iterate over all hosts, call
88 will return the first host.
90 When done with the handle,
95 .Va krb5_krbhst_info ,
96 there are two functions:
97 .Fn krb5_krbhst_format_string
98 that will return a printable representation of that struct
100 .Fn krb5_krbhst_get_addrinfo
103 that can then be used for communicating with the server mentioned.
105 The following code will print the KDCs of the realm
107 .Bd -literal -offset indent
108 krb5_krbhst_handle handle;
109 char host[MAXHOSTNAMELEN];
110 krb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
111 while(krb5_krbhst_next_as_string(context, handle,
112 host, sizeof(host)) == 0)
113 printf("%s\\n", host);
114 krb5_krbhst_free(context, handle);
118 These functions first appeared in Heimdal 0.3g.
121 .Xr krb5_get_krbhst 3