source: vendor/current/nsswitch/libwbclient/wbclient.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 54.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 Winbind client API
5
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2009
8 Copyright (C) Matthew Newton 2015
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 3 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#ifndef _WBCLIENT_H
25#define _WBCLIENT_H
26
27#include <pwd.h>
28#include <grp.h>
29
30/* Define error types */
31
32/**
33 * @brief Status codes returned from wbc functions
34 **/
35
36enum _wbcErrType {
37 WBC_ERR_SUCCESS = 0, /**< Successful completion **/
38 WBC_ERR_NOT_IMPLEMENTED,/**< Function not implemented **/
39 WBC_ERR_UNKNOWN_FAILURE,/**< General failure **/
40 WBC_ERR_NO_MEMORY, /**< Memory allocation error **/
41 WBC_ERR_INVALID_SID, /**< Invalid SID format **/
42 WBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
43 WBC_ERR_WINBIND_NOT_AVAILABLE, /**< Winbind daemon is not available **/
44 WBC_ERR_DOMAIN_NOT_FOUND, /**< Domain is not trusted or cannot be found **/
45 WBC_ERR_INVALID_RESPONSE, /**< Winbind returned an invalid response **/
46 WBC_ERR_NSS_ERROR, /**< NSS_STATUS error **/
47 WBC_ERR_AUTH_ERROR, /**< Authentication failed **/
48 WBC_ERR_UNKNOWN_USER, /**< User account cannot be found */
49 WBC_ERR_UNKNOWN_GROUP, /**< Group account cannot be found */
50 WBC_ERR_PWD_CHANGE_FAILED /**< Password Change has failed */
51};
52
53typedef enum _wbcErrType wbcErr;
54
55#define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
56
57const char *wbcErrorString(wbcErr error);
58
59/**
60 * @brief Some useful details about the wbclient library
61 *
62 * 0.1: Initial version
63 * 0.2: Added wbcRemoveUidMapping()
64 * Added wbcRemoveGidMapping()
65 * 0.3: Added wbcGetpwsid()
66 * Added wbcGetSidAliases()
67 * 0.4: Added wbcSidTypeString()
68 * 0.5: Added wbcChangeTrustCredentials()
69 * 0.6: Made struct wbcInterfaceDetails char* members non-const
70 * 0.7: Added wbcSidToStringBuf()
71 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids()
72 * 0.9: Added support for WBC_ID_TYPE_BOTH
73 * 0.10: Added wbcPingDc2()
74 * 0.11: Extended wbcAuthenticateUserEx to provide PAC parsing
75 * 0.12: Added wbcCtxCreate and friends
76 **/
77#define WBCLIENT_MAJOR_VERSION 0
78#define WBCLIENT_MINOR_VERSION 12
79#define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
80struct wbcLibraryDetails {
81 uint16_t major_version;
82 uint16_t minor_version;
83 const char *vendor_version;
84};
85
86/**
87 * @brief Some useful details about the running winbindd
88 *
89 **/
90struct wbcInterfaceDetails {
91 uint32_t interface_version;
92 char *winbind_version;
93 char winbind_separator;
94 char *netbios_name;
95 char *netbios_domain;
96 char *dns_domain;
97};
98
99/**
100 * @brief Library context data
101 *
102 **/
103
104struct wbcContext;
105
106/*
107 * Data types used by the Winbind Client API
108 */
109
110#ifndef WBC_MAXSUBAUTHS
111#define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
112#endif
113
114/**
115 * @brief Windows Security Identifier
116 *
117 **/
118
119struct wbcDomainSid {
120 uint8_t sid_rev_num;
121 uint8_t num_auths;
122 uint8_t id_auth[6];
123 uint32_t sub_auths[WBC_MAXSUBAUTHS];
124};
125
126/**
127 * @brief Security Identifier type
128 **/
129
130enum wbcSidType {
131 WBC_SID_NAME_USE_NONE=0,
132 WBC_SID_NAME_USER=1,
133 WBC_SID_NAME_DOM_GRP=2,
134 WBC_SID_NAME_DOMAIN=3,
135 WBC_SID_NAME_ALIAS=4,
136 WBC_SID_NAME_WKN_GRP=5,
137 WBC_SID_NAME_DELETED=6,
138 WBC_SID_NAME_INVALID=7,
139 WBC_SID_NAME_UNKNOWN=8,
140 WBC_SID_NAME_COMPUTER=9
141};
142
143/**
144 * @brief Security Identifier with attributes
145 **/
146
147struct wbcSidWithAttr {
148 struct wbcDomainSid sid;
149 uint32_t attributes;
150};
151
152/* wbcSidWithAttr->attributes */
153
154#define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
155#define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
156#define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
157#define WBC_SID_ATTR_GROUP_OWNER 0x00000008
158#define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
159#define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
160#define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
161
162/**
163 * @brief Windows GUID
164 *
165 **/
166
167struct wbcGuid {
168 uint32_t time_low;
169 uint16_t time_mid;
170 uint16_t time_hi_and_version;
171 uint8_t clock_seq[2];
172 uint8_t node[6];
173};
174
175/**
176 * @brief Domain Information
177 **/
178
179struct wbcDomainInfo {
180 char *short_name;
181 char *dns_name;
182 struct wbcDomainSid sid;
183 uint32_t domain_flags;
184 uint32_t trust_flags;
185 uint32_t trust_type;
186};
187
188/* wbcDomainInfo->domain_flags */
189
190#define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
191#define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
192#define WBC_DOMINFO_DOMAIN_AD 0x00000002
193#define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
194#define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
195
196/* wbcDomainInfo->trust_flags */
197
198#define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
199#define WBC_DOMINFO_TRUST_INCOMING 0x00000002
200#define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
201
202/* wbcDomainInfo->trust_type */
203
204#define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
205#define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
206#define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
207#define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
208
209/**
210 * @brief Generic Blob
211 **/
212
213struct wbcBlob {
214 uint8_t *data;
215 size_t length;
216};
217
218/**
219 * @brief Named Blob
220 **/
221
222struct wbcNamedBlob {
223 const char *name;
224 uint32_t flags;
225 struct wbcBlob blob;
226};
227
228/**
229 * @brief Auth User Parameters
230 **/
231
232struct wbcAuthUserParams {
233 const char *account_name;
234 const char *domain_name;
235 const char *workstation_name;
236
237 uint32_t flags;
238
239 uint32_t parameter_control;
240
241 enum wbcAuthUserLevel {
242 WBC_AUTH_USER_LEVEL_PLAIN = 1,
243 WBC_AUTH_USER_LEVEL_HASH = 2,
244 WBC_AUTH_USER_LEVEL_RESPONSE = 3,
245 WBC_AUTH_USER_LEVEL_PAC = 4
246 } level;
247 union {
248 const char *plaintext;
249 struct {
250 uint8_t nt_hash[16];
251 uint8_t lm_hash[16];
252 } hash;
253 struct {
254 uint8_t challenge[8];
255 uint32_t nt_length;
256 uint8_t *nt_data;
257 uint32_t lm_length;
258 uint8_t *lm_data;
259 } response;
260 struct wbcBlob pac;
261 } password;
262};
263
264/**
265 * @brief Logon User Parameters
266 **/
267
268struct wbcLogonUserParams {
269 const char *username;
270 const char *password;
271 size_t num_blobs;
272 struct wbcNamedBlob *blobs;
273};
274
275/**
276 * @brief ChangePassword Parameters
277 **/
278
279struct wbcChangePasswordParams {
280 const char *account_name;
281 const char *domain_name;
282
283 uint32_t flags;
284
285 enum wbcChangePasswordLevel {
286 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
287 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
288 } level;
289
290 union {
291 const char *plaintext;
292 struct {
293 uint32_t old_nt_hash_enc_length;
294 uint8_t *old_nt_hash_enc_data;
295 uint32_t old_lm_hash_enc_length;
296 uint8_t *old_lm_hash_enc_data;
297 } response;
298 } old_password;
299 union {
300 const char *plaintext;
301 struct {
302 uint32_t nt_length;
303 uint8_t *nt_data;
304 uint32_t lm_length;
305 uint8_t *lm_data;
306 } response;
307 } new_password;
308};
309
310/* wbcAuthUserParams->parameter_control */
311
312#define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
313#define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
314#define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
315#define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
316#define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
317#define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
318
319/* wbcAuthUserParams->flags */
320
321#define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
322
323/**
324 * @brief Auth User Information
325 *
326 * Some of the strings are maybe NULL
327 **/
328
329struct wbcAuthUserInfo {
330 uint32_t user_flags;
331
332 char *account_name;
333 char *user_principal;
334 char *full_name;
335 char *domain_name;
336 char *dns_domain_name;
337
338 uint32_t acct_flags;
339 uint8_t user_session_key[16];
340 uint8_t lm_session_key[8];
341
342 uint16_t logon_count;
343 uint16_t bad_password_count;
344
345 uint64_t logon_time;
346 uint64_t logoff_time;
347 uint64_t kickoff_time;
348 uint64_t pass_last_set_time;
349 uint64_t pass_can_change_time;
350 uint64_t pass_must_change_time;
351
352 char *logon_server;
353 char *logon_script;
354 char *profile_path;
355 char *home_directory;
356 char *home_drive;
357
358 /*
359 * the 1st one is the account sid
360 * the 2nd one is the primary_group sid
361 * followed by the rest of the groups
362 */
363 uint32_t num_sids;
364 struct wbcSidWithAttr *sids;
365};
366
367/**
368 * @brief Logon User Information
369 *
370 * Some of the strings are maybe NULL
371 **/
372
373struct wbcLogonUserInfo {
374 struct wbcAuthUserInfo *info;
375 size_t num_blobs;
376 struct wbcNamedBlob *blobs;
377};
378
379/* wbcAuthUserInfo->user_flags */
380
381#define WBC_AUTH_USER_INFO_GUEST 0x00000001
382#define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
383#define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
384#define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
385#define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
386#define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
387#define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
388#define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
389#define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
390#define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
391#define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
392
393/* wbcAuthUserInfo->acct_flags */
394
395#define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
396#define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
397#define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
398#define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
399#define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
400#define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
401#define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
402#define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
403#define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
404#define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
405#define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
406#define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
407#define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
408#define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
409#define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
410#define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
411#define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
412#define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
413#define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
414
415struct wbcAuthErrorInfo {
416 uint32_t nt_status;
417 char *nt_string;
418 int32_t pam_error;
419 char *display_string;
420};
421
422/**
423 * @brief User Password Policy Information
424 **/
425
426/* wbcUserPasswordPolicyInfo->password_properties */
427
428#define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
429#define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
430#define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
431#define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
432#define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
433#define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
434
435struct wbcUserPasswordPolicyInfo {
436 uint32_t min_length_password;
437 uint32_t password_history;
438 uint32_t password_properties;
439 uint64_t expire;
440 uint64_t min_passwordage;
441};
442
443/**
444 * @brief Change Password Reject Reason
445 **/
446
447enum wbcPasswordChangeRejectReason {
448 WBC_PWD_CHANGE_NO_ERROR=0,
449 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
450 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
451 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
452 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
453 WBC_PWD_CHANGE_NOT_COMPLEX=5,
454 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
455 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
456 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
457};
458
459/* Note: this defines exist for compatibility reasons with existing code */
460#define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
461#define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
462#define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
463#define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
464
465/**
466 * @brief Logoff User Parameters
467 **/
468
469struct wbcLogoffUserParams {
470 const char *username;
471 size_t num_blobs;
472 struct wbcNamedBlob *blobs;
473};
474
475/** @brief Credential cache log-on parameters
476 *
477 */
478
479struct wbcCredentialCacheParams {
480 const char *account_name;
481 const char *domain_name;
482 enum wbcCredentialCacheLevel {
483 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
484 } level;
485 size_t num_blobs;
486 struct wbcNamedBlob *blobs;
487};
488
489
490/** @brief Info returned by credential cache auth
491 *
492 */
493
494struct wbcCredentialCacheInfo {
495 size_t num_blobs;
496 struct wbcNamedBlob *blobs;
497};
498
499/*
500 * DomainControllerInfo struct
501 */
502struct wbcDomainControllerInfo {
503 char *dc_name;
504};
505
506/*
507 * DomainControllerInfoEx struct
508 */
509struct wbcDomainControllerInfoEx {
510 const char *dc_unc;
511 const char *dc_address;
512 uint16_t dc_address_type;
513 struct wbcGuid *domain_guid;
514 const char *domain_name;
515 const char *forest_name;
516 uint32_t dc_flags;
517 const char *dc_site_name;
518 const char *client_site_name;
519};
520
521/**********************************************************
522 * Memory Management
523 **********************************************************/
524
525/**
526 * @brief Free library allocated memory
527 *
528 * @param * Pointer to free
529 *
530 * @return void
531 **/
532void wbcFreeMemory(void*);
533
534
535/**********************************************************
536 * Context Management
537 **********************************************************/
538
539/**
540 * @brief Create a new wbcContext context
541 *
542 * @return wbcContext
543 **/
544struct wbcContext *wbcCtxCreate(void);
545
546/**
547 * @brief Free a library context
548 *
549 * @param ctx wbcContext to free
550 *
551 * @return void
552 **/
553void wbcCtxFree(struct wbcContext *ctx);
554
555
556
557/*
558 * Utility functions for dealing with SIDs
559 */
560
561/**
562 * @brief Get a string representation of the SID type
563 *
564 * @param type type of the SID
565 *
566 * @return string representation of the SID type
567 */
568const char* wbcSidTypeString(enum wbcSidType type);
569
570#define WBC_SID_STRING_BUFLEN (15*11+25)
571
572/*
573 * @brief Print a sid into a buffer
574 *
575 * @param sid Binary Security Identifier
576 * @param buf Target buffer
577 * @param buflen Target buffer length
578 *
579 * @return Resulting string length.
580 */
581int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen);
582
583/**
584 * @brief Convert a binary SID to a character string
585 *
586 * @param sid Binary Security Identifier
587 * @param **sid_string Resulting character string
588 *
589 * @return #wbcErr
590 **/
591wbcErr wbcSidToString(const struct wbcDomainSid *sid,
592 char **sid_string);
593
594/**
595 * @brief Convert a character string to a binary SID
596 *
597 * @param *sid_string Character string in the form of S-...
598 * @param sid Resulting binary SID
599 *
600 * @return #wbcErr
601 **/
602wbcErr wbcStringToSid(const char *sid_string,
603 struct wbcDomainSid *sid);
604
605/*
606 * Utility functions for dealing with GUIDs
607 */
608
609/**
610 * @brief Convert a binary GUID to a character string
611 *
612 * @param guid Binary Guid
613 * @param **guid_string Resulting character string
614 *
615 * @return #wbcErr
616 **/
617wbcErr wbcGuidToString(const struct wbcGuid *guid,
618 char **guid_string);
619
620/**
621 * @brief Convert a character string to a binary GUID
622 *
623 * @param *guid_string Character string
624 * @param guid Resulting binary GUID
625 *
626 * @return #wbcErr
627 **/
628wbcErr wbcStringToGuid(const char *guid_string,
629 struct wbcGuid *guid);
630
631/**
632 * @brief Ping winbindd to see if the daemon is running
633 *
634 * @param *ctx wbclient Context
635 *
636 * @return #wbcErr
637 **/
638wbcErr wbcCtxPing(struct wbcContext *ctx);
639
640/**
641 * @brief Ping winbindd to see if the daemon is running
642 *
643 * @return #wbcErr
644 **/
645wbcErr wbcPing(void);
646
647wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
648
649wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
650 struct wbcInterfaceDetails **details);
651wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
652
653/**********************************************************
654 * Name/SID conversion
655 **********************************************************/
656
657/**
658 * @brief Convert a domain and name to SID
659 *
660 * @param *ctx wbclient Context
661 * @param dom_name Domain name (possibly "")
662 * @param name User or group name
663 * @param *sid Pointer to the resolved domain SID
664 * @param *name_type Pointer to the SID type
665 *
666 * @return #wbcErr
667 **/
668wbcErr wbcCtxLookupName(struct wbcContext *ctx,
669 const char *dom_name,
670 const char *name,
671 struct wbcDomainSid *sid,
672 enum wbcSidType *name_type);
673
674/**
675 * @brief Convert a domain and name to SID
676 *
677 * @param dom_name Domain name (possibly "")
678 * @param name User or group name
679 * @param *sid Pointer to the resolved domain SID
680 * @param *name_type Pointer to the SID type
681 *
682 * @return #wbcErr
683 **/
684wbcErr wbcLookupName(const char *dom_name,
685 const char *name,
686 struct wbcDomainSid *sid,
687 enum wbcSidType *name_type);
688
689/**
690 * @brief Convert a SID to a domain and name
691 *
692 * @param *ctx wbclient Context
693 * @param *sid Pointer to the domain SID to be resolved
694 * @param domain Resolved Domain name (possibly "")
695 * @param name Resolved User or group name
696 * @param *name_type Pointer to the resolved SID type
697 *
698 * @return #wbcErr
699 **/
700wbcErr wbcCtxLookupSid(struct wbcContext *ctx,
701 const struct wbcDomainSid *sid,
702 char **domain,
703 char **name,
704 enum wbcSidType *name_type);
705
706/**
707 * @brief Convert a SID to a domain and name
708 *
709 * @param *sid Pointer to the domain SID to be resolved
710 * @param domain Resolved Domain name (possibly "")
711 * @param name Resolved User or group name
712 * @param *name_type Pointer to the resolved SID type
713 *
714 * @return #wbcErr
715 **/
716wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
717 char **domain,
718 char **name,
719 enum wbcSidType *name_type);
720
721struct wbcTranslatedName {
722 enum wbcSidType type;
723 char *name;
724 int domain_index;
725};
726
727wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
728 const struct wbcDomainSid *sids, int num_sids,
729 struct wbcDomainInfo **domains, int *num_domains,
730 struct wbcTranslatedName **names);
731
732wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
733 struct wbcDomainInfo **domains, int *num_domains,
734 struct wbcTranslatedName **names);
735
736/**
737 * @brief Translate a collection of RIDs within a domain to names
738 */
739wbcErr wbcCtxLookupRids(struct wbcContext *ctx,
740 struct wbcDomainSid *dom_sid,
741 int num_rids,
742 uint32_t *rids,
743 const char **domain_name,
744 const char ***names,
745 enum wbcSidType **types);
746
747/**
748 * @brief Translate a collection of RIDs within a domain to names
749 */
750wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
751 int num_rids,
752 uint32_t *rids,
753 const char **domain_name,
754 const char ***names,
755 enum wbcSidType **types);
756
757/*
758 * @brief Get the groups a user belongs to
759 **/
760wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx,
761 const struct wbcDomainSid *user_sid,
762 bool domain_groups_only,
763 uint32_t *num_sids,
764 struct wbcDomainSid **sids);
765
766/*
767 * @brief Get the groups a user belongs to
768 **/
769wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
770 bool domain_groups_only,
771 uint32_t *num_sids,
772 struct wbcDomainSid **sids);
773
774/*
775 * @brief Get alias membership for sids
776 **/
777wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx,
778 const struct wbcDomainSid *dom_sid,
779 struct wbcDomainSid *sids,
780 uint32_t num_sids,
781 uint32_t **alias_rids,
782 uint32_t *num_alias_rids);
783
784/*
785 * @brief Get alias membership for sids
786 **/
787wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
788 struct wbcDomainSid *sids,
789 uint32_t num_sids,
790 uint32_t **alias_rids,
791 uint32_t *num_alias_rids);
792
793/**
794 * @brief Lists Users
795 **/
796wbcErr wbcCtxListUsers(struct wbcContext *ctx,
797 const char *domain_name,
798 uint32_t *num_users,
799 const char ***users);
800
801/**
802 * @brief Lists Users
803 **/
804wbcErr wbcListUsers(const char *domain_name,
805 uint32_t *num_users,
806 const char ***users);
807
808/**
809 * @brief Lists Groups
810 **/
811wbcErr wbcCtxListGroups(struct wbcContext *ctx,
812 const char *domain_name,
813 uint32_t *num_groups,
814 const char ***groups);
815
816/**
817 * @brief Lists Groups
818 **/
819wbcErr wbcListGroups(const char *domain_name,
820 uint32_t *num_groups,
821 const char ***groups);
822
823wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx,
824 const struct wbcDomainSid *sid,
825 char **pdomain,
826 char **pfullname,
827 enum wbcSidType *pname_type);
828
829wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
830 char **pdomain,
831 char **pfullname,
832 enum wbcSidType *pname_type);
833
834/**********************************************************
835 * SID/uid/gid Mappings
836 **********************************************************/
837
838/**
839 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
840 *
841 * @param *ctx wbclient Context
842 * @param *sid Pointer to the domain SID to be resolved
843 * @param *puid Pointer to the resolved uid_t value
844 *
845 * @return #wbcErr
846 *
847 **/
848wbcErr wbcCtxSidToUid(struct wbcContext *ctx,
849 const struct wbcDomainSid *sid,
850 uid_t *puid);
851
852/**
853 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
854 *
855 * @param *sid Pointer to the domain SID to be resolved
856 * @param *puid Pointer to the resolved uid_t value
857 *
858 * @return #wbcErr
859 *
860 **/
861wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
862 uid_t *puid);
863
864/**
865 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
866 *
867 * @param *sid Pointer to the domain SID to be resolved
868 * @param *puid Pointer to the resolved uid_t value
869 *
870 * @return #wbcErr
871 *
872 **/
873wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
874 uid_t *puid);
875
876/**
877 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
878 *
879 * @param *ctx wbclient Context
880 * @param uid Unix uid to be resolved
881 * @param *sid Pointer to the resolved domain SID
882 *
883 * @return #wbcErr
884 *
885 **/
886wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid,
887 struct wbcDomainSid *sid);
888
889/**
890 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
891 *
892 * @param uid Unix uid to be resolved
893 * @param *sid Pointer to the resolved domain SID
894 *
895 * @return #wbcErr
896 *
897 **/
898wbcErr wbcUidToSid(uid_t uid,
899 struct wbcDomainSid *sid);
900
901/**
902 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
903 *
904 * @param uid Unix uid to be resolved
905 * @param *sid Pointer to the resolved domain SID
906 *
907 * @return #wbcErr
908 *
909 **/
910wbcErr wbcQueryUidToSid(uid_t uid,
911 struct wbcDomainSid *sid);
912
913/**
914 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
915 *
916 * @param *ctx wbclient Context
917 * @param *sid Pointer to the domain SID to be resolved
918 * @param *pgid Pointer to the resolved gid_t value
919 *
920 * @return #wbcErr
921 *
922 **/
923wbcErr wbcCtxSidToGid(struct wbcContext *ctx,
924 const struct wbcDomainSid *sid,
925 gid_t *pgid);
926
927/**
928 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
929 *
930 * @param *sid Pointer to the domain SID to be resolved
931 * @param *pgid Pointer to the resolved gid_t value
932 *
933 * @return #wbcErr
934 *
935 **/
936wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
937 gid_t *pgid);
938
939/**
940 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
941 *
942 * @param *sid Pointer to the domain SID to be resolved
943 * @param *pgid Pointer to the resolved gid_t value
944 *
945 * @return #wbcErr
946 *
947 **/
948wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
949 gid_t *pgid);
950
951/**
952 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
953 *
954 * @param *ctx wbclient Context
955 * @param gid Unix gid to be resolved
956 * @param *sid Pointer to the resolved domain SID
957 *
958 * @return #wbcErr
959 *
960 **/
961wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid,
962 struct wbcDomainSid *sid);
963
964/**
965 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
966 *
967 * @param gid Unix gid to be resolved
968 * @param *sid Pointer to the resolved domain SID
969 *
970 * @return #wbcErr
971 *
972 **/
973wbcErr wbcGidToSid(gid_t gid,
974 struct wbcDomainSid *sid);
975
976/**
977 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
978 *
979 * @param gid Unix gid to be resolved
980 * @param *sid Pointer to the resolved domain SID
981 *
982 * @return #wbcErr
983 *
984 **/
985wbcErr wbcQueryGidToSid(gid_t gid,
986 struct wbcDomainSid *sid);
987
988enum wbcIdType {
989 WBC_ID_TYPE_NOT_SPECIFIED,
990 WBC_ID_TYPE_UID,
991 WBC_ID_TYPE_GID,
992 WBC_ID_TYPE_BOTH
993};
994
995union wbcUnixIdContainer {
996 uid_t uid;
997 gid_t gid;
998};
999
1000struct wbcUnixId {
1001 enum wbcIdType type;
1002 union wbcUnixIdContainer id;
1003};
1004
1005/**
1006 * @brief Convert a list of sids to unix ids
1007 *
1008 * @param *ctx wbclient Context
1009 * @param sids Pointer to an array of SIDs to convert
1010 * @param num_sids Number of SIDs
1011 * @param ids Preallocated output array for translated IDs
1012 *
1013 * @return #wbcErr
1014 *
1015 **/
1016wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
1017 const struct wbcDomainSid *sids, uint32_t num_sids,
1018 struct wbcUnixId *ids);
1019
1020/**
1021 * @brief Convert a list of sids to unix ids
1022 *
1023 * @param sids Pointer to an array of SIDs to convert
1024 * @param num_sids Number of SIDs
1025 * @param ids Preallocated output array for translated IDs
1026 *
1027 * @return #wbcErr
1028 *
1029 **/
1030wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
1031 struct wbcUnixId *ids);
1032
1033/**
1034 * @brief Obtain a new uid from Winbind
1035 *
1036 * @param *ctx wbclient Context
1037 * @param *puid Pointer to the allocated uid
1038 *
1039 * @return #wbcErr
1040 **/
1041wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid);
1042
1043/**
1044 * @brief Obtain a new uid from Winbind
1045 *
1046 * @param *puid Pointer to the allocated uid
1047 *
1048 * @return #wbcErr
1049 **/
1050wbcErr wbcAllocateUid(uid_t *puid);
1051
1052/**
1053 * @brief Obtain a new gid from Winbind
1054 *
1055 * @param *ctx wbclient Context
1056 * @param *pgid Pointer to the allocated gid
1057 *
1058 * @return #wbcErr
1059 **/
1060wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid);
1061
1062/**
1063 * @brief Obtain a new gid from Winbind
1064 *
1065 * @param *pgid Pointer to the allocated gid
1066 *
1067 * @return #wbcErr
1068 **/
1069wbcErr wbcAllocateGid(gid_t *pgid);
1070
1071/**
1072 * @brief Set an user id mapping
1073 *
1074 * @param uid Uid of the desired mapping.
1075 * @param *sid Pointer to the sid of the desired mapping.
1076 *
1077 * @return #wbcErr
1078 *
1079 * @deprecated This method is not impemented any more and should
1080 * be removed in the next major version change.
1081 **/
1082wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
1083
1084/**
1085 * @brief Set a group id mapping
1086 *
1087 * @param gid Gid of the desired mapping.
1088 * @param *sid Pointer to the sid of the desired mapping.
1089 *
1090 * @return #wbcErr
1091 *
1092 * @deprecated This method is not impemented any more and should
1093 * be removed in the next major version change.
1094 **/
1095wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
1096
1097/**
1098 * @brief Remove a user id mapping
1099 *
1100 * @param uid Uid of the mapping to remove.
1101 * @param *sid Pointer to the sid of the mapping to remove.
1102 *
1103 * @return #wbcErr
1104 *
1105 * @deprecated This method is not impemented any more and should
1106 * be removed in the next major version change.
1107 **/
1108wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
1109
1110/**
1111 * @brief Remove a group id mapping
1112 *
1113 * @param gid Gid of the mapping to remove.
1114 * @param *sid Pointer to the sid of the mapping to remove.
1115 *
1116 * @return #wbcErr
1117 *
1118 * @deprecated This method is not impemented any more and should
1119 * be removed in the next major version change.
1120 **/
1121wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
1122
1123/**
1124 * @brief Set the highwater mark for allocated uids.
1125 *
1126 * @param uid_hwm The new uid highwater mark value
1127 *
1128 * @return #wbcErr
1129 *
1130 * @deprecated This method is not impemented any more and should
1131 * be removed in the next major version change.
1132 **/
1133wbcErr wbcSetUidHwm(uid_t uid_hwm);
1134
1135/**
1136 * @brief Set the highwater mark for allocated gids.
1137 *
1138 * @param gid_hwm The new gid highwater mark value
1139 *
1140 * @return #wbcErr
1141 *
1142 * @deprecated This method is not impemented any more and should
1143 * be removed in the next major version change.
1144 **/
1145wbcErr wbcSetGidHwm(gid_t gid_hwm);
1146
1147/**********************************************************
1148 * NSS Lookup User/Group details
1149 **********************************************************/
1150
1151/**
1152 * @brief Fill in a struct passwd* for a domain user based
1153 * on username
1154 *
1155 * @param *ctx wbclient Context
1156 * @param *name Username to lookup
1157 * @param **pwd Pointer to resulting struct passwd* from the query.
1158 *
1159 * @return #wbcErr
1160 **/
1161wbcErr wbcCtxGetpwnam(struct wbcContext *ctx,
1162 const char *name, struct passwd **pwd);
1163
1164/**
1165 * @brief Fill in a struct passwd* for a domain user based
1166 * on username
1167 *
1168 * @param *name Username to lookup
1169 * @param **pwd Pointer to resulting struct passwd* from the query.
1170 *
1171 * @return #wbcErr
1172 **/
1173wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
1174
1175/**
1176 * @brief Fill in a struct passwd* for a domain user based
1177 * on uid
1178 *
1179 * @param *ctx wbclient Context
1180 * @param uid Uid to lookup
1181 * @param **pwd Pointer to resulting struct passwd* from the query.
1182 *
1183 * @return #wbcErr
1184 **/
1185wbcErr wbcCtxGetpwuid(struct wbcContext *ctx,
1186 uid_t uid, struct passwd **pwd);
1187
1188/**
1189 * @brief Fill in a struct passwd* for a domain user based
1190 * on uid
1191 *
1192 * @param uid Uid to lookup
1193 * @param **pwd Pointer to resulting struct passwd* from the query.
1194 *
1195 * @return #wbcErr
1196 **/
1197wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
1198
1199/**
1200 * @brief Fill in a struct passwd* for a domain user based
1201 * on sid
1202 *
1203 * @param *ctx wbclient Context
1204 * @param sid Sid to lookup
1205 * @param **pwd Pointer to resulting struct passwd* from the query.
1206 *
1207 * @return #wbcErr
1208 **/
1209wbcErr wbcCtxGetpwsid(struct wbcContext *ctx,
1210 struct wbcDomainSid * sid, struct passwd **pwd);
1211
1212/**
1213 * @brief Fill in a struct passwd* for a domain user based
1214 * on sid
1215 *
1216 * @param sid Sid to lookup
1217 * @param **pwd Pointer to resulting struct passwd* from the query.
1218 *
1219 * @return #wbcErr
1220 **/
1221wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
1222
1223/**
1224 * @brief Fill in a struct passwd* for a domain user based
1225 * on username
1226 *
1227 * @param *ctx wbclient Context
1228 * @param *name Username to lookup
1229 * @param **grp Pointer to resulting struct group* from the query.
1230 *
1231 * @return #wbcErr
1232 **/
1233wbcErr wbcCtxGetgrnam(struct wbcContext *ctx,
1234 const char *name, struct group **grp);
1235
1236/**
1237 * @brief Fill in a struct passwd* for a domain user based
1238 * on username
1239 *
1240 * @param *name Username to lookup
1241 * @param **grp Pointer to resulting struct group* from the query.
1242 *
1243 * @return #wbcErr
1244 **/
1245wbcErr wbcGetgrnam(const char *name, struct group **grp);
1246
1247/**
1248 * @brief Fill in a struct passwd* for a domain user based
1249 * on uid
1250 *
1251 * @param *ctx wbclient Context
1252 * @param gid Uid to lookup
1253 * @param **grp Pointer to resulting struct group* from the query.
1254 *
1255 * @return #wbcErr
1256 **/
1257wbcErr wbcCtxGetgrgid(struct wbcContext *ctx,
1258 gid_t gid, struct group **grp);
1259
1260/**
1261 * @brief Fill in a struct passwd* for a domain user based
1262 * on uid
1263 *
1264 * @param gid Uid to lookup
1265 * @param **grp Pointer to resulting struct group* from the query.
1266 *
1267 * @return #wbcErr
1268 **/
1269wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
1270
1271/**
1272 * @brief Reset the passwd iterator
1273 *
1274 * @param *ctx wbclient Context
1275 *
1276 * @return #wbcErr
1277 **/
1278wbcErr wbcCtxSetpwent(struct wbcContext *ctx);
1279
1280/**
1281 * @brief Reset the passwd iterator
1282 *
1283 * @return #wbcErr
1284 **/
1285wbcErr wbcSetpwent(void);
1286
1287/**
1288 * @brief Close the passwd iterator
1289 *
1290 * @param *ctx wbclient Context
1291 *
1292 * @return #wbcErr
1293 **/
1294wbcErr wbcCtxEndpwent(struct wbcContext *ctx);
1295
1296/**
1297 * @brief Close the passwd iterator
1298 *
1299 * @return #wbcErr
1300 **/
1301wbcErr wbcEndpwent(void);
1302
1303/**
1304 * @brief Return the next struct passwd* entry from the pwent iterator
1305 *
1306 * @param *ctx wbclient Context
1307 * @param **pwd Pointer to resulting struct passwd* from the query.
1308 *
1309 * @return #wbcErr
1310 **/
1311wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd);
1312
1313/**
1314 * @brief Return the next struct passwd* entry from the pwent iterator
1315 *
1316 * @param **pwd Pointer to resulting struct passwd* from the query.
1317 *
1318 * @return #wbcErr
1319 **/
1320wbcErr wbcGetpwent(struct passwd **pwd);
1321
1322/**
1323 * @brief Reset the group iterator
1324 *
1325 * @param *ctx wbclient Context
1326 *
1327 * @return #wbcErr
1328 **/
1329wbcErr wbcCtxSetgrent(struct wbcContext *ctx);
1330
1331/**
1332 * @brief Reset the group iterator
1333 *
1334 * @return #wbcErr
1335 **/
1336wbcErr wbcSetgrent(void);
1337
1338/**
1339 * @brief Close the group iterator
1340 *
1341 * @param *ctx wbclient Context
1342 *
1343 * @return #wbcErr
1344 **/
1345wbcErr wbcCtxEndgrent(struct wbcContext *ctx);
1346
1347/**
1348 * @brief Close the group iterator
1349 *
1350 * @return #wbcErr
1351 **/
1352wbcErr wbcEndgrent(void);
1353
1354/**
1355 * @brief Return the next struct group* entry from the pwent iterator
1356 *
1357 * @param *ctx wbclient Context
1358 * @param **grp Pointer to resulting struct group* from the query.
1359 *
1360 * @return #wbcErr
1361 **/
1362wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp);
1363
1364/**
1365 * @brief Return the next struct group* entry from the pwent iterator
1366 *
1367 * @param **grp Pointer to resulting struct group* from the query.
1368 *
1369 * @return #wbcErr
1370 **/
1371wbcErr wbcGetgrent(struct group **grp);
1372
1373/**
1374 * @brief Return the next struct group* entry from the pwent iterator
1375 *
1376 * This is similar to #wbcGetgrent, just that the member list is empty
1377 *
1378 * @param *ctx wbclient Context
1379 * @param **grp Pointer to resulting struct group* from the query.
1380 *
1381 * @return #wbcErr
1382 **/
1383wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp);
1384
1385/**
1386 * @brief Return the next struct group* entry from the pwent iterator
1387 *
1388 * This is similar to #wbcGetgrent, just that the member list is empty
1389 *
1390 * @param **grp Pointer to resulting struct group* from the query.
1391 *
1392 * @return #wbcErr
1393 **/
1394wbcErr wbcGetgrlist(struct group **grp);
1395
1396/**
1397 * @brief Return the unix group array belonging to the given user
1398 *
1399 * @param *ctx wbclient Context
1400 * @param *account The given user name
1401 * @param *num_groups Number of elements returned in the groups array
1402 * @param **_groups Pointer to resulting gid_t array.
1403 *
1404 * @return #wbcErr
1405 **/
1406wbcErr wbcCtxGetGroups(struct wbcContext *ctx,
1407 const char *account,
1408 uint32_t *num_groups,
1409 gid_t **_groups);
1410
1411/**
1412 * @brief Return the unix group array belonging to the given user
1413 *
1414 * @param *account The given user name
1415 * @param *num_groups Number of elements returned in the groups array
1416 * @param **_groups Pointer to resulting gid_t array.
1417 *
1418 * @return #wbcErr
1419 **/
1420wbcErr wbcGetGroups(const char *account,
1421 uint32_t *num_groups,
1422 gid_t **_groups);
1423
1424
1425/**********************************************************
1426 * Lookup Domain information
1427 **********************************************************/
1428
1429/**
1430 * @brief Lookup the current status of a trusted domain
1431 *
1432 * @param *ctx wbclient Context
1433 * @param domain The domain to query
1434 *
1435 * @param dinfo A pointer to store the returned domain_info struct.
1436 *
1437 * @return #wbcErr
1438 **/
1439wbcErr wbcCtxDomainInfo(struct wbcContext *ctx,
1440 const char *domain,
1441 struct wbcDomainInfo **dinfo);
1442
1443/**
1444 * @brief Lookup the current status of a trusted domain
1445 *
1446 * @param domain The domain to query
1447 *
1448 * @param dinfo A pointer to store the returned domain_info struct.
1449 *
1450 * @return #wbcErr
1451 **/
1452wbcErr wbcDomainInfo(const char *domain,
1453 struct wbcDomainInfo **dinfo);
1454
1455/**
1456 * @brief Lookup the currently contacted DCs
1457 *
1458 * @param *ctx wbclient Context
1459 * @param domain The domain to query
1460 *
1461 * @param num_dcs Number of DCs currently known
1462 * @param dc_names Names of the currently known DCs
1463 * @param dc_ips IP addresses of the currently known DCs
1464 *
1465 * @return #wbcErr
1466 **/
1467wbcErr wbcCtxDcInfo(struct wbcContext *ctx,
1468 const char *domain, size_t *num_dcs,
1469 const char ***dc_names, const char ***dc_ips);
1470
1471/**
1472 * @brief Lookup the currently contacted DCs
1473 *
1474 * @param domain The domain to query
1475 *
1476 * @param num_dcs Number of DCs currently known
1477 * @param dc_names Names of the currently known DCs
1478 * @param dc_ips IP addresses of the currently known DCs
1479 *
1480 * @return #wbcErr
1481 **/
1482wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
1483 const char ***dc_names, const char ***dc_ips);
1484
1485/**
1486 * @brief Enumerate the domain trusts known by Winbind
1487 *
1488 * @param *ctx wbclient Context
1489 * @param **domains Pointer to the allocated domain list array
1490 * @param *num_domains Pointer to number of domains returned
1491 *
1492 * @return #wbcErr
1493 **/
1494wbcErr wbcCtxListTrusts(struct wbcContext *ctx,
1495 struct wbcDomainInfo **domains,
1496 size_t *num_domains);
1497
1498/**
1499 * @brief Enumerate the domain trusts known by Winbind
1500 *
1501 * @param **domains Pointer to the allocated domain list array
1502 * @param *num_domains Pointer to number of domains returned
1503 *
1504 * @return #wbcErr
1505 **/
1506wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1507 size_t *num_domains);
1508
1509/* Flags for wbcLookupDomainController */
1510
1511#define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1512#define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1513#define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1514#define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1515#define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1516#define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1517#define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1518#define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1519#define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1520#define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1521#define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1522#define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1523#define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1524#define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1525#define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1526#define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1527#define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1528#define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1529#define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1530
1531/**
1532 * @brief Enumerate the domain trusts known by Winbind
1533 *
1534 * @param *ctx wbclient Context
1535 * @param domain Name of the domain to query for a DC
1536 * @param flags Bit flags used to control the domain location query
1537 * @param *dc_info Pointer to the returned domain controller information
1538 *
1539 * @return #wbcErr
1540 **/
1541wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx,
1542 const char *domain,
1543 uint32_t flags,
1544 struct wbcDomainControllerInfo **dc_info);
1545
1546/**
1547 * @brief Enumerate the domain trusts known by Winbind
1548 *
1549 * @param domain Name of the domain to query for a DC
1550 * @param flags Bit flags used to control the domain location query
1551 * @param *dc_info Pointer to the returned domain controller information
1552 *
1553 * @return #wbcErr
1554 **/
1555wbcErr wbcLookupDomainController(const char *domain,
1556 uint32_t flags,
1557 struct wbcDomainControllerInfo **dc_info);
1558
1559/**
1560 * @brief Get extended domain controller information
1561 *
1562 * @param *ctx wbclient Context
1563 * @param domain Name of the domain to query for a DC
1564 * @param guid Guid of the domain to query for a DC
1565 * @param site Site of the domain to query for a DC
1566 * @param flags Bit flags used to control the domain location query
1567 * @param *dc_info Pointer to the returned extended domain controller information
1568 *
1569 * @return #wbcErr
1570 **/
1571wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx,
1572 const char *domain,
1573 struct wbcGuid *guid,
1574 const char *site,
1575 uint32_t flags,
1576 struct wbcDomainControllerInfoEx **dc_info);
1577
1578/**
1579 * @brief Get extended domain controller information
1580 *
1581 * @param domain Name of the domain to query for a DC
1582 * @param guid Guid of the domain to query for a DC
1583 * @param site Site of the domain to query for a DC
1584 * @param flags Bit flags used to control the domain location query
1585 * @param *dc_info Pointer to the returned extended domain controller information
1586 *
1587 * @return #wbcErr
1588 **/
1589wbcErr wbcLookupDomainControllerEx(const char *domain,
1590 struct wbcGuid *guid,
1591 const char *site,
1592 uint32_t flags,
1593 struct wbcDomainControllerInfoEx **dc_info);
1594
1595/**********************************************************
1596 * Athenticate functions
1597 **********************************************************/
1598
1599/**
1600 * @brief Authenticate a username/password pair
1601 *
1602 * @param *ctx wbclient Context
1603 * @param username Name of user to authenticate
1604 * @param password Clear text password os user
1605 *
1606 * @return #wbcErr
1607 **/
1608wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx,
1609 const char *username,
1610 const char *password);
1611
1612/**
1613 * @brief Authenticate a username/password pair
1614 *
1615 * @param username Name of user to authenticate
1616 * @param password Clear text password os user
1617 *
1618 * @return #wbcErr
1619 **/
1620wbcErr wbcAuthenticateUser(const char *username,
1621 const char *password);
1622
1623/**
1624 * @brief Authenticate with more detailed information
1625 *
1626 * @param *ctx wbclient Context
1627 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1628 * is not supported yet
1629 * @param info Output details on WBC_ERR_SUCCESS
1630 * @param error Output details on WBC_ERR_AUTH_ERROR
1631 *
1632 * @return #wbcErr
1633 **/
1634wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx,
1635 const struct wbcAuthUserParams *params,
1636 struct wbcAuthUserInfo **info,
1637 struct wbcAuthErrorInfo **error);
1638
1639/**
1640 * @brief Authenticate with more detailed information
1641 *
1642 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1643 * is not supported yet
1644 * @param info Output details on WBC_ERR_SUCCESS
1645 * @param error Output details on WBC_ERR_AUTH_ERROR
1646 *
1647 * @return #wbcErr
1648 **/
1649wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1650 struct wbcAuthUserInfo **info,
1651 struct wbcAuthErrorInfo **error);
1652
1653/**
1654 * @brief Logon a User
1655 *
1656 * @param[in] *ctx wbclient Context
1657 * @param[in] params Pointer to a wbcLogonUserParams structure
1658 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1659 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1660 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1661 *
1662 * @return #wbcErr
1663 **/
1664wbcErr wbcCtxLogonUser(struct wbcContext *ctx,
1665 const struct wbcLogonUserParams *params,
1666 struct wbcLogonUserInfo **info,
1667 struct wbcAuthErrorInfo **error,
1668 struct wbcUserPasswordPolicyInfo **policy);
1669
1670/**
1671 * @brief Logon a User
1672 *
1673 * @param[in] params Pointer to a wbcLogonUserParams structure
1674 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1675 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1676 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1677 *
1678 * @return #wbcErr
1679 **/
1680wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1681 struct wbcLogonUserInfo **info,
1682 struct wbcAuthErrorInfo **error,
1683 struct wbcUserPasswordPolicyInfo **policy);
1684
1685/**
1686 * @brief Trigger a logoff notification to Winbind for a specific user
1687 *
1688 * @param *ctx wbclient Context
1689 * @param username Name of user to remove from Winbind's list of
1690 * logged on users.
1691 * @param uid Uid assigned to the username
1692 * @param ccfilename Absolute path to the Krb5 credentials cache to
1693 * be removed
1694 *
1695 * @return #wbcErr
1696 **/
1697wbcErr wbcCtxLogoffUser(struct wbcContext *ctx,
1698 const char *username, uid_t uid,
1699 const char *ccfilename);
1700
1701/**
1702 * @brief Trigger a logoff notification to Winbind for a specific user
1703 *
1704 * @param username Name of user to remove from Winbind's list of
1705 * logged on users.
1706 * @param uid Uid assigned to the username
1707 * @param ccfilename Absolute path to the Krb5 credentials cache to
1708 * be removed
1709 *
1710 * @return #wbcErr
1711 **/
1712wbcErr wbcLogoffUser(const char *username,
1713 uid_t uid,
1714 const char *ccfilename);
1715
1716/**
1717 * @brief Trigger an extended logoff notification to Winbind for a specific user
1718 *
1719 * @param *ctx wbclient Context
1720 * @param params A wbcLogoffUserParams structure
1721 * @param error User output details on error
1722 *
1723 * @return #wbcErr
1724 **/
1725wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx,
1726 const struct wbcLogoffUserParams *params,
1727 struct wbcAuthErrorInfo **error);
1728
1729/**
1730 * @brief Trigger an extended logoff notification to Winbind for a specific user
1731 *
1732 * @param params A wbcLogoffUserParams structure
1733 * @param error User output details on error
1734 *
1735 * @return #wbcErr
1736 **/
1737wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1738 struct wbcAuthErrorInfo **error);
1739
1740/**
1741 * @brief Change a password for a user
1742 *
1743 * @param *ctx wbclient Context
1744 * @param username Name of user to authenticate
1745 * @param old_password Old clear text password of user
1746 * @param new_password New clear text password of user
1747 *
1748 * @return #wbcErr
1749 **/
1750wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx,
1751 const char *username,
1752 const char *old_password,
1753 const char *new_password);
1754
1755/**
1756 * @brief Change a password for a user
1757 *
1758 * @param username Name of user to authenticate
1759 * @param old_password Old clear text password of user
1760 * @param new_password New clear text password of user
1761 *
1762 * @return #wbcErr
1763 **/
1764wbcErr wbcChangeUserPassword(const char *username,
1765 const char *old_password,
1766 const char *new_password);
1767
1768/**
1769 * @brief Change a password for a user with more detailed information upon
1770 * failure
1771 *
1772 * @param *ctx wbclient Context
1773 * @param params Input parameters
1774 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1775 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1776 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1777 *
1778 * @return #wbcErr
1779 **/
1780wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx,
1781 const struct wbcChangePasswordParams *params,
1782 struct wbcAuthErrorInfo **error,
1783 enum wbcPasswordChangeRejectReason *reject_reason,
1784 struct wbcUserPasswordPolicyInfo **policy);
1785
1786/**
1787 * @brief Change a password for a user with more detailed information upon
1788 * failure
1789 *
1790 * @param params Input parameters
1791 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1792 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1793 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1794 *
1795 * @return #wbcErr
1796 **/
1797wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1798 struct wbcAuthErrorInfo **error,
1799 enum wbcPasswordChangeRejectReason *reject_reason,
1800 struct wbcUserPasswordPolicyInfo **policy);
1801
1802/**
1803 * @brief Authenticate a user with cached credentials
1804 *
1805 * @param *ctx wbclient Context
1806 * @param *params Pointer to a wbcCredentialCacheParams structure
1807 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1808 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1809 *
1810 * @return #wbcErr
1811 **/
1812wbcErr wbcCtxCredentialCache(struct wbcContext *ctx,
1813 struct wbcCredentialCacheParams *params,
1814 struct wbcCredentialCacheInfo **info,
1815 struct wbcAuthErrorInfo **error);
1816
1817/**
1818 * @brief Authenticate a user with cached credentials
1819 *
1820 * @param *params Pointer to a wbcCredentialCacheParams structure
1821 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1822 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1823 *
1824 * @return #wbcErr
1825 **/
1826wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1827 struct wbcCredentialCacheInfo **info,
1828 struct wbcAuthErrorInfo **error);
1829
1830/**
1831 * @brief Save a password with winbind for doing wbcCredentialCache() later
1832 *
1833 * @param *ctx wbclient Context
1834 * @param *user Username
1835 * @param *password Password
1836 *
1837 * @return #wbcErr
1838 **/
1839wbcErr wbcCtxCredentialSave(struct wbcContext *ctx,
1840 const char *user, const char *password);
1841
1842/**
1843 * @brief Save a password with winbind for doing wbcCredentialCache() later
1844 *
1845 * @param *user Username
1846 * @param *password Password
1847 *
1848 * @return #wbcErr
1849 **/
1850wbcErr wbcCredentialSave(const char *user, const char *password);
1851
1852/**********************************************************
1853 * Resolve functions
1854 **********************************************************/
1855
1856/**
1857 * @brief Resolve a NetbiosName via WINS
1858 *
1859 * @param *ctx wbclient Context
1860 * @param name Name to resolve
1861 * @param *ip Pointer to the ip address string
1862 *
1863 * @return #wbcErr
1864 **/
1865wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx,
1866 const char *name, char **ip);
1867
1868/**
1869 * @brief Resolve a NetbiosName via WINS
1870 *
1871 * @param name Name to resolve
1872 * @param *ip Pointer to the ip address string
1873 *
1874 * @return #wbcErr
1875 **/
1876wbcErr wbcResolveWinsByName(const char *name, char **ip);
1877
1878/**
1879 * @brief Resolve an IP address via WINS into a NetbiosName
1880 *
1881 * @param *ctx wbclient Context
1882 * @param ip The ip address string
1883 * @param *name Pointer to the name
1884 *
1885 * @return #wbcErr
1886 *
1887 **/
1888wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx,
1889 const char *ip, char **name);
1890
1891/**
1892 * @brief Resolve an IP address via WINS into a NetbiosName
1893 *
1894 * @param ip The ip address string
1895 * @param *name Pointer to the name
1896 *
1897 * @return #wbcErr
1898 *
1899 **/
1900wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1901
1902/**********************************************************
1903 * Trusted domain functions
1904 **********************************************************/
1905
1906/**
1907 * @brief Trigger a verification of the trust credentials of a specific domain
1908 *
1909 * @param *ctx wbclient Context
1910 * @param *domain The name of the domain.
1911 * @param error Output details on WBC_ERR_AUTH_ERROR
1912 *
1913 * @return #wbcErr
1914 **/
1915wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain,
1916 struct wbcAuthErrorInfo **error);
1917
1918/**
1919 * @brief Trigger a verification of the trust credentials of a specific domain
1920 *
1921 * @param *domain The name of the domain.
1922 * @param error Output details on WBC_ERR_AUTH_ERROR
1923 *
1924 * @return #wbcErr
1925 **/
1926wbcErr wbcCheckTrustCredentials(const char *domain,
1927 struct wbcAuthErrorInfo **error);
1928
1929/**
1930 * @brief Trigger a change of the trust credentials for a specific domain
1931 *
1932 * @param *ctx wbclient Context
1933 * @param *domain The name of the domain.
1934 * @param error Output details on WBC_ERR_AUTH_ERROR
1935 *
1936 * @return #wbcErr
1937 **/
1938wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain,
1939 struct wbcAuthErrorInfo **error);
1940
1941/**
1942 * @brief Trigger a change of the trust credentials for a specific domain
1943 *
1944 * @param *domain The name of the domain.
1945 * @param error Output details on WBC_ERR_AUTH_ERROR
1946 *
1947 * @return #wbcErr
1948 **/
1949wbcErr wbcChangeTrustCredentials(const char *domain,
1950 struct wbcAuthErrorInfo **error);
1951
1952/**
1953 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1954 * version of wbcCheckTrustCredentials
1955 *
1956 * @param *ctx wbclient Context
1957 * @param *domain The name of the domain, only NULL for the default domain is
1958 * supported yet. Other values than NULL will result in
1959 * WBC_ERR_NOT_IMPLEMENTED.
1960 * @param error Output details on WBC_ERR_AUTH_ERROR
1961 *
1962 * @return #wbcErr
1963 **/
1964wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain,
1965 struct wbcAuthErrorInfo **error);
1966
1967/**
1968 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1969 * version of wbcCheckTrustCredentials
1970 *
1971 * @param *domain The name of the domain, only NULL for the default domain is
1972 * supported yet. Other values than NULL will result in
1973 * WBC_ERR_NOT_IMPLEMENTED.
1974 * @param error Output details on WBC_ERR_AUTH_ERROR
1975 *
1976 * @return #wbcErr
1977 **/
1978wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1979
1980/**
1981 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1982 * version of wbcCheckTrustCredentials
1983 *
1984 * @param *ctx wbclient Context
1985 * @param *domain The name of the domain, only NULL for the default domain is
1986 * supported yet. Other values than NULL will result in
1987 * WBC_ERR_NOT_IMPLEMENTED.
1988 * @param error Output details on WBC_ERR_AUTH_ERROR
1989 * @param dcname DC that was attempted to ping
1990 *
1991 * @return #wbcErr
1992 **/
1993wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain,
1994 struct wbcAuthErrorInfo **error,
1995 char **dcname);
1996
1997/**
1998 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1999 * version of wbcCheckTrustCredentials
2000 *
2001 * @param *domain The name of the domain, only NULL for the default domain is
2002 * supported yet. Other values than NULL will result in
2003 * WBC_ERR_NOT_IMPLEMENTED.
2004 * @param error Output details on WBC_ERR_AUTH_ERROR
2005 * @param dcname DC that was attempted to ping
2006 *
2007 * @return #wbcErr
2008 **/
2009wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
2010 char **dcname);
2011
2012/**********************************************************
2013 * Helper functions
2014 **********************************************************/
2015
2016/**
2017 * @brief Initialize a named blob and add to list of blobs
2018 *
2019 * @param[in,out] num_blobs Pointer to the number of blobs
2020 * @param[in,out] blobs Pointer to an array of blobs
2021 * @param[in] name Name of the new named blob
2022 * @param[in] flags Flags of the new named blob
2023 * @param[in] data Blob data of new blob
2024 * @param[in] length Blob data length of new blob
2025 *
2026 * @return #wbcErr
2027 **/
2028wbcErr wbcAddNamedBlob(size_t *num_blobs,
2029 struct wbcNamedBlob **blobs,
2030 const char *name,
2031 uint32_t flags,
2032 uint8_t *data,
2033 size_t length);
2034
2035#endif /* _WBCLIENT_H */
Note: See TracBrowser for help on using the repository browser.