ctdb-common: Do not queue a packet if queue does not have valid fd
[Samba.git] / nsswitch / libwbclient / wbclient.h
blobed97a673739acbc56be33624bab39374ec7335cc
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind client API
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2009
8 Copyright (C) Matthew Newton 2015
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.
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.
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/>.
24 #ifndef _WBCLIENT_H
25 #define _WBCLIENT_H
27 #include <pwd.h>
28 #include <grp.h>
30 /* Define error types */
32 /**
33 * @brief Status codes returned from wbc functions
34 **/
36 enum _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 */
53 typedef enum _wbcErrType wbcErr;
55 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
57 const char *wbcErrorString(wbcErr error);
59 /**
60 * @brief Some useful details about the wbclient library
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 * 0.13: Added wbcCtxUnixIdsToSids and wbcUnixIdsToSids
77 * 0.14: Added "authoritative" to wbcAuthErrorInfo
78 * Added WBC_SID_NAME_LABEL
79 **/
80 #define WBCLIENT_MAJOR_VERSION 0
81 #define WBCLIENT_MINOR_VERSION 14
82 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
83 struct wbcLibraryDetails {
84 uint16_t major_version;
85 uint16_t minor_version;
86 const char *vendor_version;
89 /**
90 * @brief Some useful details about the running winbindd
92 **/
93 struct wbcInterfaceDetails {
94 uint32_t interface_version;
95 char *winbind_version;
96 char winbind_separator;
97 char *netbios_name;
98 char *netbios_domain;
99 char *dns_domain;
103 * @brief Library context data
107 struct wbcContext;
110 * Data types used by the Winbind Client API
113 #ifndef WBC_MAXSUBAUTHS
114 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
115 #endif
118 * @brief Windows Security Identifier
122 struct wbcDomainSid {
123 uint8_t sid_rev_num;
124 uint8_t num_auths;
125 uint8_t id_auth[6];
126 uint32_t sub_auths[WBC_MAXSUBAUTHS];
130 * @brief Security Identifier type
133 enum wbcSidType {
134 WBC_SID_NAME_USE_NONE=0,
135 WBC_SID_NAME_USER=1,
136 WBC_SID_NAME_DOM_GRP=2,
137 WBC_SID_NAME_DOMAIN=3,
138 WBC_SID_NAME_ALIAS=4,
139 WBC_SID_NAME_WKN_GRP=5,
140 WBC_SID_NAME_DELETED=6,
141 WBC_SID_NAME_INVALID=7,
142 WBC_SID_NAME_UNKNOWN=8,
143 WBC_SID_NAME_COMPUTER=9,
144 WBC_SID_NAME_LABEL=10
148 * @brief Security Identifier with attributes
151 struct wbcSidWithAttr {
152 struct wbcDomainSid sid;
153 uint32_t attributes;
156 /* wbcSidWithAttr->attributes */
158 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
159 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
160 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
161 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
162 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
163 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
164 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
167 * @brief Windows GUID
171 struct wbcGuid {
172 uint32_t time_low;
173 uint16_t time_mid;
174 uint16_t time_hi_and_version;
175 uint8_t clock_seq[2];
176 uint8_t node[6];
180 * @brief Domain Information
183 struct wbcDomainInfo {
184 char *short_name;
185 char *dns_name;
186 struct wbcDomainSid sid;
187 uint32_t domain_flags;
188 uint32_t trust_flags;
189 uint32_t trust_type;
192 /* wbcDomainInfo->domain_flags */
194 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
195 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
196 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
197 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
198 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
200 /* wbcDomainInfo->trust_flags */
202 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
203 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
204 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
206 /* wbcDomainInfo->trust_type */
208 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
209 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
210 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
211 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
214 * @brief Generic Blob
217 struct wbcBlob {
218 uint8_t *data;
219 size_t length;
223 * @brief Named Blob
226 struct wbcNamedBlob {
227 const char *name;
228 uint32_t flags;
229 struct wbcBlob blob;
233 * @brief Auth User Parameters
236 struct wbcAuthUserParams {
237 const char *account_name;
238 const char *domain_name;
239 const char *workstation_name;
241 uint32_t flags;
243 uint32_t parameter_control;
245 enum wbcAuthUserLevel {
246 WBC_AUTH_USER_LEVEL_PLAIN = 1,
247 WBC_AUTH_USER_LEVEL_HASH = 2,
248 WBC_AUTH_USER_LEVEL_RESPONSE = 3,
249 WBC_AUTH_USER_LEVEL_PAC = 4
250 } level;
251 union {
252 const char *plaintext;
253 struct {
254 uint8_t nt_hash[16];
255 uint8_t lm_hash[16];
256 } hash;
257 struct {
258 uint8_t challenge[8];
259 uint32_t nt_length;
260 uint8_t *nt_data;
261 uint32_t lm_length;
262 uint8_t *lm_data;
263 } response;
264 struct wbcBlob pac;
265 } password;
269 * @brief Logon User Parameters
272 struct wbcLogonUserParams {
273 const char *username;
274 const char *password;
275 size_t num_blobs;
276 struct wbcNamedBlob *blobs;
280 * @brief ChangePassword Parameters
283 struct wbcChangePasswordParams {
284 const char *account_name;
285 const char *domain_name;
287 uint32_t flags;
289 enum wbcChangePasswordLevel {
290 WBC_CHANGE_PASSWORD_LEVEL_PLAIN = 1,
291 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE = 2
292 } level;
294 union {
295 const char *plaintext;
296 struct {
297 uint32_t old_nt_hash_enc_length;
298 uint8_t *old_nt_hash_enc_data;
299 uint32_t old_lm_hash_enc_length;
300 uint8_t *old_lm_hash_enc_data;
301 } response;
302 } old_password;
303 union {
304 const char *plaintext;
305 struct {
306 uint32_t nt_length;
307 uint8_t *nt_data;
308 uint32_t lm_length;
309 uint8_t *lm_data;
310 } response;
311 } new_password;
314 /* wbcAuthUserParams->parameter_control */
316 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
317 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
318 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
319 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
320 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
321 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
322 #define WBC_MSV1_0_ALLOW_MSVCHAPV2 0x00010000
324 /* wbcAuthUserParams->flags */
326 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
329 * @brief Auth User Information
331 * Some of the strings are maybe NULL
334 struct wbcAuthUserInfo {
335 uint32_t user_flags;
337 char *account_name;
338 char *user_principal;
339 char *full_name;
340 char *domain_name;
341 char *dns_domain_name;
343 uint32_t acct_flags;
344 uint8_t user_session_key[16];
345 uint8_t lm_session_key[8];
347 uint16_t logon_count;
348 uint16_t bad_password_count;
350 uint64_t logon_time;
351 uint64_t logoff_time;
352 uint64_t kickoff_time;
353 uint64_t pass_last_set_time;
354 uint64_t pass_can_change_time;
355 uint64_t pass_must_change_time;
357 char *logon_server;
358 char *logon_script;
359 char *profile_path;
360 char *home_directory;
361 char *home_drive;
364 * the 1st one is the account sid
365 * the 2nd one is the primary_group sid
366 * followed by the rest of the groups
368 uint32_t num_sids;
369 struct wbcSidWithAttr *sids;
373 * @brief Logon User Information
375 * Some of the strings are maybe NULL
378 struct wbcLogonUserInfo {
379 struct wbcAuthUserInfo *info;
380 size_t num_blobs;
381 struct wbcNamedBlob *blobs;
384 /* wbcAuthUserInfo->user_flags */
386 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
387 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
388 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
389 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
390 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
391 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
392 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
393 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
394 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
395 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
396 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
398 /* wbcAuthUserInfo->acct_flags */
400 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
401 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
402 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
403 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
404 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
405 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
406 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
407 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
408 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
409 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
410 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
411 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
412 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
413 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
414 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
415 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
416 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
417 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
418 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
420 struct wbcAuthErrorInfo {
421 uint32_t nt_status;
422 char *nt_string;
423 int32_t pam_error;
424 char *display_string;
425 uint8_t authoritative;
429 * @brief User Password Policy Information
432 /* wbcUserPasswordPolicyInfo->password_properties */
434 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
435 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
436 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
437 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
438 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
439 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
441 struct wbcUserPasswordPolicyInfo {
442 uint32_t min_length_password;
443 uint32_t password_history;
444 uint32_t password_properties;
445 uint64_t expire;
446 uint64_t min_passwordage;
450 * @brief Change Password Reject Reason
453 enum wbcPasswordChangeRejectReason {
454 WBC_PWD_CHANGE_NO_ERROR=0,
455 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT=1,
456 WBC_PWD_CHANGE_PWD_IN_HISTORY=2,
457 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD=3,
458 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD=4,
459 WBC_PWD_CHANGE_NOT_COMPLEX=5,
460 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT=6,
461 WBC_PWD_CHANGE_FAILED_BY_FILTER=7,
462 WBC_PWD_CHANGE_PASSWORD_TOO_LONG=8
465 /* Note: this defines exist for compatibility reasons with existing code */
466 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
467 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
468 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
469 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
472 * @brief Logoff User Parameters
475 struct wbcLogoffUserParams {
476 const char *username;
477 size_t num_blobs;
478 struct wbcNamedBlob *blobs;
481 /** @brief Credential cache log-on parameters
485 struct wbcCredentialCacheParams {
486 const char *account_name;
487 const char *domain_name;
488 enum wbcCredentialCacheLevel {
489 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP = 1
490 } level;
491 size_t num_blobs;
492 struct wbcNamedBlob *blobs;
496 /** @brief Info returned by credential cache auth
500 struct wbcCredentialCacheInfo {
501 size_t num_blobs;
502 struct wbcNamedBlob *blobs;
506 * DomainControllerInfo struct
508 struct wbcDomainControllerInfo {
509 char *dc_name;
513 * DomainControllerInfoEx struct
515 struct wbcDomainControllerInfoEx {
516 const char *dc_unc;
517 const char *dc_address;
518 uint16_t dc_address_type;
519 struct wbcGuid *domain_guid;
520 const char *domain_name;
521 const char *forest_name;
522 uint32_t dc_flags;
523 const char *dc_site_name;
524 const char *client_site_name;
527 /**********************************************************
528 * Memory Management
529 **********************************************************/
532 * @brief Free library allocated memory
534 * @param * Pointer to free
536 * @return void
538 void wbcFreeMemory(void*);
541 /**********************************************************
542 * Context Management
543 **********************************************************/
546 * @brief Create a new wbcContext context
548 * @return wbcContext
550 struct wbcContext *wbcCtxCreate(void);
553 * @brief Free a library context
555 * @param ctx wbcContext to free
557 * @return void
559 void wbcCtxFree(struct wbcContext *ctx);
564 * Utility functions for dealing with SIDs
568 * @brief Get a string representation of the SID type
570 * @param type type of the SID
572 * @return string representation of the SID type
574 const char* wbcSidTypeString(enum wbcSidType type);
576 #define WBC_SID_STRING_BUFLEN (15*11+25)
579 * @brief Print a sid into a buffer
581 * @param sid Binary Security Identifier
582 * @param buf Target buffer
583 * @param buflen Target buffer length
585 * @return Resulting string length.
587 int wbcSidToStringBuf(const struct wbcDomainSid *sid, char *buf, int buflen);
590 * @brief Convert a binary SID to a character string
592 * @param sid Binary Security Identifier
593 * @param **sid_string Resulting character string
595 * @return #wbcErr
597 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
598 char **sid_string);
601 * @brief Convert a character string to a binary SID
603 * @param *sid_string Character string in the form of S-...
604 * @param sid Resulting binary SID
606 * @return #wbcErr
608 wbcErr wbcStringToSid(const char *sid_string,
609 struct wbcDomainSid *sid);
612 * Utility functions for dealing with GUIDs
616 * @brief Convert a binary GUID to a character string
618 * @param guid Binary Guid
619 * @param **guid_string Resulting character string
621 * @return #wbcErr
623 wbcErr wbcGuidToString(const struct wbcGuid *guid,
624 char **guid_string);
627 * @brief Convert a character string to a binary GUID
629 * @param *guid_string Character string
630 * @param guid Resulting binary GUID
632 * @return #wbcErr
634 wbcErr wbcStringToGuid(const char *guid_string,
635 struct wbcGuid *guid);
638 * @brief Ping winbindd to see if the daemon is running
640 * @param *ctx wbclient Context
642 * @return #wbcErr
644 wbcErr wbcCtxPing(struct wbcContext *ctx);
647 * @brief Ping winbindd to see if the daemon is running
649 * @return #wbcErr
651 wbcErr wbcPing(void);
653 wbcErr wbcLibraryDetails(struct wbcLibraryDetails **details);
655 wbcErr wbcCtxInterfaceDetails(struct wbcContext *ctx,
656 struct wbcInterfaceDetails **details);
657 wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **details);
659 /**********************************************************
660 * Name/SID conversion
661 **********************************************************/
664 * @brief Convert a domain and name to SID
666 * @param *ctx wbclient Context
667 * @param dom_name Domain name (possibly "")
668 * @param name User or group name
669 * @param *sid Pointer to the resolved domain SID
670 * @param *name_type Pointer to the SID type
672 * @return #wbcErr
674 wbcErr wbcCtxLookupName(struct wbcContext *ctx,
675 const char *dom_name,
676 const char *name,
677 struct wbcDomainSid *sid,
678 enum wbcSidType *name_type);
681 * @brief Convert a domain and name to SID
683 * @param dom_name Domain name (possibly "")
684 * @param name User or group name
685 * @param *sid Pointer to the resolved domain SID
686 * @param *name_type Pointer to the SID type
688 * @return #wbcErr
690 wbcErr wbcLookupName(const char *dom_name,
691 const char *name,
692 struct wbcDomainSid *sid,
693 enum wbcSidType *name_type);
696 * @brief Convert a SID to a domain and name
698 * @param *ctx wbclient Context
699 * @param *sid Pointer to the domain SID to be resolved
700 * @param domain Resolved Domain name (possibly "")
701 * @param name Resolved User or group name
702 * @param *name_type Pointer to the resolved SID type
704 * @return #wbcErr
706 wbcErr wbcCtxLookupSid(struct wbcContext *ctx,
707 const struct wbcDomainSid *sid,
708 char **domain,
709 char **name,
710 enum wbcSidType *name_type);
713 * @brief Convert a SID to a domain and name
715 * @param *sid Pointer to the domain SID to be resolved
716 * @param domain Resolved Domain name (possibly "")
717 * @param name Resolved User or group name
718 * @param *name_type Pointer to the resolved SID type
720 * @return #wbcErr
722 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
723 char **domain,
724 char **name,
725 enum wbcSidType *name_type);
727 struct wbcTranslatedName {
728 enum wbcSidType type;
729 char *name;
730 int domain_index;
733 wbcErr wbcCtxLookupSids(struct wbcContext *ctx,
734 const struct wbcDomainSid *sids, int num_sids,
735 struct wbcDomainInfo **domains, int *num_domains,
736 struct wbcTranslatedName **names);
738 wbcErr wbcLookupSids(const struct wbcDomainSid *sids, int num_sids,
739 struct wbcDomainInfo **domains, int *num_domains,
740 struct wbcTranslatedName **names);
743 * @brief Translate a collection of RIDs within a domain to names
745 wbcErr wbcCtxLookupRids(struct wbcContext *ctx,
746 struct wbcDomainSid *dom_sid,
747 int num_rids,
748 uint32_t *rids,
749 const char **domain_name,
750 const char ***names,
751 enum wbcSidType **types);
754 * @brief Translate a collection of RIDs within a domain to names
756 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
757 int num_rids,
758 uint32_t *rids,
759 const char **domain_name,
760 const char ***names,
761 enum wbcSidType **types);
764 * @brief Get the groups a user belongs to
766 wbcErr wbcCtxLookupUserSids(struct wbcContext *ctx,
767 const struct wbcDomainSid *user_sid,
768 bool domain_groups_only,
769 uint32_t *num_sids,
770 struct wbcDomainSid **sids);
773 * @brief Get the groups a user belongs to
775 wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
776 bool domain_groups_only,
777 uint32_t *num_sids,
778 struct wbcDomainSid **sids);
781 * @brief Get alias membership for sids
783 wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx,
784 const struct wbcDomainSid *dom_sid,
785 struct wbcDomainSid *sids,
786 uint32_t num_sids,
787 uint32_t **alias_rids,
788 uint32_t *num_alias_rids);
791 * @brief Get alias membership for sids
793 wbcErr wbcGetSidAliases(const struct wbcDomainSid *dom_sid,
794 struct wbcDomainSid *sids,
795 uint32_t num_sids,
796 uint32_t **alias_rids,
797 uint32_t *num_alias_rids);
800 * @brief Lists Users
802 wbcErr wbcCtxListUsers(struct wbcContext *ctx,
803 const char *domain_name,
804 uint32_t *num_users,
805 const char ***users);
808 * @brief Lists Users
810 wbcErr wbcListUsers(const char *domain_name,
811 uint32_t *num_users,
812 const char ***users);
815 * @brief Lists Groups
817 wbcErr wbcCtxListGroups(struct wbcContext *ctx,
818 const char *domain_name,
819 uint32_t *num_groups,
820 const char ***groups);
823 * @brief Lists Groups
825 wbcErr wbcListGroups(const char *domain_name,
826 uint32_t *num_groups,
827 const char ***groups);
829 wbcErr wbcCtxGetDisplayName(struct wbcContext *ctx,
830 const struct wbcDomainSid *sid,
831 char **pdomain,
832 char **pfullname,
833 enum wbcSidType *pname_type);
835 wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
836 char **pdomain,
837 char **pfullname,
838 enum wbcSidType *pname_type);
840 /**********************************************************
841 * SID/uid/gid Mappings
842 **********************************************************/
845 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
847 * @param *ctx wbclient Context
848 * @param *sid Pointer to the domain SID to be resolved
849 * @param *puid Pointer to the resolved uid_t value
851 * @return #wbcErr
854 wbcErr wbcCtxSidToUid(struct wbcContext *ctx,
855 const struct wbcDomainSid *sid,
856 uid_t *puid);
859 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
861 * @param *sid Pointer to the domain SID to be resolved
862 * @param *puid Pointer to the resolved uid_t value
864 * @return #wbcErr
867 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
868 uid_t *puid);
871 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
873 * @param *sid Pointer to the domain SID to be resolved
874 * @param *puid Pointer to the resolved uid_t value
876 * @return #wbcErr
879 wbcErr wbcQuerySidToUid(const struct wbcDomainSid *sid,
880 uid_t *puid);
883 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
885 * @param *ctx wbclient Context
886 * @param uid Unix uid to be resolved
887 * @param *sid Pointer to the resolved domain SID
889 * @return #wbcErr
892 wbcErr wbcCtxUidToSid(struct wbcContext *ctx, uid_t uid,
893 struct wbcDomainSid *sid);
896 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
898 * @param uid Unix uid to be resolved
899 * @param *sid Pointer to the resolved domain SID
901 * @return #wbcErr
904 wbcErr wbcUidToSid(uid_t uid,
905 struct wbcDomainSid *sid);
908 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
910 * @param uid Unix uid to be resolved
911 * @param *sid Pointer to the resolved domain SID
913 * @return #wbcErr
916 wbcErr wbcQueryUidToSid(uid_t uid,
917 struct wbcDomainSid *sid);
920 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
922 * @param *ctx wbclient Context
923 * @param *sid Pointer to the domain SID to be resolved
924 * @param *pgid Pointer to the resolved gid_t value
926 * @return #wbcErr
929 wbcErr wbcCtxSidToGid(struct wbcContext *ctx,
930 const struct wbcDomainSid *sid,
931 gid_t *pgid);
934 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
936 * @param *sid Pointer to the domain SID to be resolved
937 * @param *pgid Pointer to the resolved gid_t value
939 * @return #wbcErr
942 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
943 gid_t *pgid);
946 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
948 * @param *sid Pointer to the domain SID to be resolved
949 * @param *pgid Pointer to the resolved gid_t value
951 * @return #wbcErr
954 wbcErr wbcQuerySidToGid(const struct wbcDomainSid *sid,
955 gid_t *pgid);
958 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
960 * @param *ctx wbclient Context
961 * @param gid Unix gid to be resolved
962 * @param *sid Pointer to the resolved domain SID
964 * @return #wbcErr
967 wbcErr wbcCtxGidToSid(struct wbcContext *ctx, gid_t gid,
968 struct wbcDomainSid *sid);
971 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
973 * @param gid Unix gid to be resolved
974 * @param *sid Pointer to the resolved domain SID
976 * @return #wbcErr
979 wbcErr wbcGidToSid(gid_t gid,
980 struct wbcDomainSid *sid);
983 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
985 * @param gid Unix gid to be resolved
986 * @param *sid Pointer to the resolved domain SID
988 * @return #wbcErr
991 wbcErr wbcQueryGidToSid(gid_t gid,
992 struct wbcDomainSid *sid);
994 enum wbcIdType {
995 WBC_ID_TYPE_NOT_SPECIFIED,
996 WBC_ID_TYPE_UID,
997 WBC_ID_TYPE_GID,
998 WBC_ID_TYPE_BOTH
1001 union wbcUnixIdContainer {
1002 uid_t uid;
1003 gid_t gid;
1006 struct wbcUnixId {
1007 enum wbcIdType type;
1008 union wbcUnixIdContainer id;
1012 * @brief Convert a list of sids to unix ids
1014 * @param *ctx wbclient Context
1015 * @param sids Pointer to an array of SIDs to convert
1016 * @param num_sids Number of SIDs
1017 * @param ids Preallocated output array for translated IDs
1019 * @return #wbcErr
1022 wbcErr wbcCtxSidsToUnixIds(struct wbcContext *ctx,
1023 const struct wbcDomainSid *sids, uint32_t num_sids,
1024 struct wbcUnixId *ids);
1027 * @brief Convert a list of sids to unix ids
1029 * @param sids Pointer to an array of SIDs to convert
1030 * @param num_sids Number of SIDs
1031 * @param ids Preallocated output array for translated IDs
1033 * @return #wbcErr
1036 wbcErr wbcSidsToUnixIds(const struct wbcDomainSid *sids, uint32_t num_sids,
1037 struct wbcUnixId *ids);
1039 wbcErr wbcCtxUnixIdsToSids(struct wbcContext *ctx,
1040 const struct wbcUnixId *ids, uint32_t num_ids,
1041 struct wbcDomainSid *sids);
1042 wbcErr wbcUnixIdsToSids(const struct wbcUnixId *ids, uint32_t num_ids,
1043 struct wbcDomainSid *sids);
1046 * @brief Obtain a new uid from Winbind
1048 * @param *ctx wbclient Context
1049 * @param *puid Pointer to the allocated uid
1051 * @return #wbcErr
1053 wbcErr wbcCtxAllocateUid(struct wbcContext *ctx, uid_t *puid);
1056 * @brief Obtain a new uid from Winbind
1058 * @param *puid Pointer to the allocated uid
1060 * @return #wbcErr
1062 wbcErr wbcAllocateUid(uid_t *puid);
1065 * @brief Obtain a new gid from Winbind
1067 * @param *ctx wbclient Context
1068 * @param *pgid Pointer to the allocated gid
1070 * @return #wbcErr
1072 wbcErr wbcCtxAllocateGid(struct wbcContext *ctx, gid_t *pgid);
1075 * @brief Obtain a new gid from Winbind
1077 * @param *pgid Pointer to the allocated gid
1079 * @return #wbcErr
1081 wbcErr wbcAllocateGid(gid_t *pgid);
1084 * @brief Set an user id mapping
1086 * @param uid Uid of the desired mapping.
1087 * @param *sid Pointer to the sid of the desired mapping.
1089 * @return #wbcErr
1091 * @deprecated This method is not impemented any more and should
1092 * be removed in the next major version change.
1094 wbcErr wbcSetUidMapping(uid_t uid, const struct wbcDomainSid *sid);
1097 * @brief Set a group id mapping
1099 * @param gid Gid of the desired mapping.
1100 * @param *sid Pointer to the sid of the desired mapping.
1102 * @return #wbcErr
1104 * @deprecated This method is not impemented any more and should
1105 * be removed in the next major version change.
1107 wbcErr wbcSetGidMapping(gid_t gid, const struct wbcDomainSid *sid);
1110 * @brief Remove a user id mapping
1112 * @param uid Uid of the mapping to remove.
1113 * @param *sid Pointer to the sid of the mapping to remove.
1115 * @return #wbcErr
1117 * @deprecated This method is not impemented any more and should
1118 * be removed in the next major version change.
1120 wbcErr wbcRemoveUidMapping(uid_t uid, const struct wbcDomainSid *sid);
1123 * @brief Remove a group id mapping
1125 * @param gid Gid of the mapping to remove.
1126 * @param *sid Pointer to the sid of the mapping to remove.
1128 * @return #wbcErr
1130 * @deprecated This method is not impemented any more and should
1131 * be removed in the next major version change.
1133 wbcErr wbcRemoveGidMapping(gid_t gid, const struct wbcDomainSid *sid);
1136 * @brief Set the highwater mark for allocated uids.
1138 * @param uid_hwm The new uid highwater mark value
1140 * @return #wbcErr
1142 * @deprecated This method is not impemented any more and should
1143 * be removed in the next major version change.
1145 wbcErr wbcSetUidHwm(uid_t uid_hwm);
1148 * @brief Set the highwater mark for allocated gids.
1150 * @param gid_hwm The new gid highwater mark value
1152 * @return #wbcErr
1154 * @deprecated This method is not impemented any more and should
1155 * be removed in the next major version change.
1157 wbcErr wbcSetGidHwm(gid_t gid_hwm);
1159 /**********************************************************
1160 * NSS Lookup User/Group details
1161 **********************************************************/
1164 * @brief Fill in a struct passwd* for a domain user based
1165 * on username
1167 * @param *ctx wbclient Context
1168 * @param *name Username to lookup
1169 * @param **pwd Pointer to resulting struct passwd* from the query.
1171 * @return #wbcErr
1173 wbcErr wbcCtxGetpwnam(struct wbcContext *ctx,
1174 const char *name, struct passwd **pwd);
1177 * @brief Fill in a struct passwd* for a domain user based
1178 * on username
1180 * @param *name Username to lookup
1181 * @param **pwd Pointer to resulting struct passwd* from the query.
1183 * @return #wbcErr
1185 wbcErr wbcGetpwnam(const char *name, struct passwd **pwd);
1188 * @brief Fill in a struct passwd* for a domain user based
1189 * on uid
1191 * @param *ctx wbclient Context
1192 * @param uid Uid to lookup
1193 * @param **pwd Pointer to resulting struct passwd* from the query.
1195 * @return #wbcErr
1197 wbcErr wbcCtxGetpwuid(struct wbcContext *ctx,
1198 uid_t uid, struct passwd **pwd);
1201 * @brief Fill in a struct passwd* for a domain user based
1202 * on uid
1204 * @param uid Uid to lookup
1205 * @param **pwd Pointer to resulting struct passwd* from the query.
1207 * @return #wbcErr
1209 wbcErr wbcGetpwuid(uid_t uid, struct passwd **pwd);
1212 * @brief Fill in a struct passwd* for a domain user based
1213 * on sid
1215 * @param *ctx wbclient Context
1216 * @param sid Sid to lookup
1217 * @param **pwd Pointer to resulting struct passwd* from the query.
1219 * @return #wbcErr
1221 wbcErr wbcCtxGetpwsid(struct wbcContext *ctx,
1222 struct wbcDomainSid * sid, struct passwd **pwd);
1225 * @brief Fill in a struct passwd* for a domain user based
1226 * on sid
1228 * @param sid Sid to lookup
1229 * @param **pwd Pointer to resulting struct passwd* from the query.
1231 * @return #wbcErr
1233 wbcErr wbcGetpwsid(struct wbcDomainSid * sid, struct passwd **pwd);
1236 * @brief Fill in a struct passwd* for a domain user based
1237 * on username
1239 * @param *ctx wbclient Context
1240 * @param *name Username to lookup
1241 * @param **grp Pointer to resulting struct group* from the query.
1243 * @return #wbcErr
1245 wbcErr wbcCtxGetgrnam(struct wbcContext *ctx,
1246 const char *name, struct group **grp);
1249 * @brief Fill in a struct passwd* for a domain user based
1250 * on username
1252 * @param *name Username to lookup
1253 * @param **grp Pointer to resulting struct group* from the query.
1255 * @return #wbcErr
1257 wbcErr wbcGetgrnam(const char *name, struct group **grp);
1260 * @brief Fill in a struct passwd* for a domain user based
1261 * on uid
1263 * @param *ctx wbclient Context
1264 * @param gid Uid to lookup
1265 * @param **grp Pointer to resulting struct group* from the query.
1267 * @return #wbcErr
1269 wbcErr wbcCtxGetgrgid(struct wbcContext *ctx,
1270 gid_t gid, struct group **grp);
1273 * @brief Fill in a struct passwd* for a domain user based
1274 * on uid
1276 * @param gid Uid to lookup
1277 * @param **grp Pointer to resulting struct group* from the query.
1279 * @return #wbcErr
1281 wbcErr wbcGetgrgid(gid_t gid, struct group **grp);
1284 * @brief Reset the passwd iterator
1286 * @param *ctx wbclient Context
1288 * @return #wbcErr
1290 wbcErr wbcCtxSetpwent(struct wbcContext *ctx);
1293 * @brief Reset the passwd iterator
1295 * @return #wbcErr
1297 wbcErr wbcSetpwent(void);
1300 * @brief Close the passwd iterator
1302 * @param *ctx wbclient Context
1304 * @return #wbcErr
1306 wbcErr wbcCtxEndpwent(struct wbcContext *ctx);
1309 * @brief Close the passwd iterator
1311 * @return #wbcErr
1313 wbcErr wbcEndpwent(void);
1316 * @brief Return the next struct passwd* entry from the pwent iterator
1318 * @param *ctx wbclient Context
1319 * @param **pwd Pointer to resulting struct passwd* from the query.
1321 * @return #wbcErr
1323 wbcErr wbcCtxGetpwent(struct wbcContext *ctx, struct passwd **pwd);
1326 * @brief Return the next struct passwd* entry from the pwent iterator
1328 * @param **pwd Pointer to resulting struct passwd* from the query.
1330 * @return #wbcErr
1332 wbcErr wbcGetpwent(struct passwd **pwd);
1335 * @brief Reset the group iterator
1337 * @param *ctx wbclient Context
1339 * @return #wbcErr
1341 wbcErr wbcCtxSetgrent(struct wbcContext *ctx);
1344 * @brief Reset the group iterator
1346 * @return #wbcErr
1348 wbcErr wbcSetgrent(void);
1351 * @brief Close the group iterator
1353 * @param *ctx wbclient Context
1355 * @return #wbcErr
1357 wbcErr wbcCtxEndgrent(struct wbcContext *ctx);
1360 * @brief Close the group iterator
1362 * @return #wbcErr
1364 wbcErr wbcEndgrent(void);
1367 * @brief Return the next struct group* entry from the pwent iterator
1369 * @param *ctx wbclient Context
1370 * @param **grp Pointer to resulting struct group* from the query.
1372 * @return #wbcErr
1374 wbcErr wbcCtxGetgrent(struct wbcContext *ctx, struct group **grp);
1377 * @brief Return the next struct group* entry from the pwent iterator
1379 * @param **grp Pointer to resulting struct group* from the query.
1381 * @return #wbcErr
1383 wbcErr wbcGetgrent(struct group **grp);
1386 * @brief Return the next struct group* entry from the pwent iterator
1388 * This is similar to #wbcGetgrent, just that the member list is empty
1390 * @param *ctx wbclient Context
1391 * @param **grp Pointer to resulting struct group* from the query.
1393 * @return #wbcErr
1395 wbcErr wbcCtxGetgrlist(struct wbcContext *ctx, struct group **grp);
1398 * @brief Return the next struct group* entry from the pwent iterator
1400 * This is similar to #wbcGetgrent, just that the member list is empty
1402 * @param **grp Pointer to resulting struct group* from the query.
1404 * @return #wbcErr
1406 wbcErr wbcGetgrlist(struct group **grp);
1409 * @brief Return the unix group array belonging to the given user
1411 * @param *ctx wbclient Context
1412 * @param *account The given user name
1413 * @param *num_groups Number of elements returned in the groups array
1414 * @param **_groups Pointer to resulting gid_t array.
1416 * @return #wbcErr
1418 wbcErr wbcCtxGetGroups(struct wbcContext *ctx,
1419 const char *account,
1420 uint32_t *num_groups,
1421 gid_t **_groups);
1424 * @brief Return the unix group array belonging to the given user
1426 * @param *account The given user name
1427 * @param *num_groups Number of elements returned in the groups array
1428 * @param **_groups Pointer to resulting gid_t array.
1430 * @return #wbcErr
1432 wbcErr wbcGetGroups(const char *account,
1433 uint32_t *num_groups,
1434 gid_t **_groups);
1437 /**********************************************************
1438 * Lookup Domain information
1439 **********************************************************/
1442 * @brief Lookup the current status of a trusted domain
1444 * @param *ctx wbclient Context
1445 * @param domain The domain to query
1447 * @param dinfo A pointer to store the returned domain_info struct.
1449 * @return #wbcErr
1451 wbcErr wbcCtxDomainInfo(struct wbcContext *ctx,
1452 const char *domain,
1453 struct wbcDomainInfo **dinfo);
1456 * @brief Lookup the current status of a trusted domain
1458 * @param domain The domain to query
1460 * @param dinfo A pointer to store the returned domain_info struct.
1462 * @return #wbcErr
1464 wbcErr wbcDomainInfo(const char *domain,
1465 struct wbcDomainInfo **dinfo);
1468 * @brief Lookup the currently contacted DCs
1470 * @param *ctx wbclient Context
1471 * @param domain The domain to query
1473 * @param num_dcs Number of DCs currently known
1474 * @param dc_names Names of the currently known DCs
1475 * @param dc_ips IP addresses of the currently known DCs
1477 * @return #wbcErr
1479 wbcErr wbcCtxDcInfo(struct wbcContext *ctx,
1480 const char *domain, size_t *num_dcs,
1481 const char ***dc_names, const char ***dc_ips);
1484 * @brief Lookup the currently contacted DCs
1486 * @param domain The domain to query
1488 * @param num_dcs Number of DCs currently known
1489 * @param dc_names Names of the currently known DCs
1490 * @param dc_ips IP addresses of the currently known DCs
1492 * @return #wbcErr
1494 wbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
1495 const char ***dc_names, const char ***dc_ips);
1498 * @brief Enumerate the domain trusts known by Winbind
1500 * @param *ctx wbclient Context
1501 * @param **domains Pointer to the allocated domain list array
1502 * @param *num_domains Pointer to number of domains returned
1504 * @return #wbcErr
1506 wbcErr wbcCtxListTrusts(struct wbcContext *ctx,
1507 struct wbcDomainInfo **domains,
1508 size_t *num_domains);
1511 * @brief Enumerate the domain trusts known by Winbind
1513 * @param **domains Pointer to the allocated domain list array
1514 * @param *num_domains Pointer to number of domains returned
1516 * @return #wbcErr
1518 wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
1519 size_t *num_domains);
1521 /* Flags for wbcLookupDomainController */
1523 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1524 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1525 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1526 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1527 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1528 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1529 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1530 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1531 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1532 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1533 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1534 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1535 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1536 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1537 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1538 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1539 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1540 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1541 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1544 * @brief Enumerate the domain trusts known by Winbind
1546 * @param *ctx wbclient Context
1547 * @param domain Name of the domain to query for a DC
1548 * @param flags Bit flags used to control the domain location query
1549 * @param *dc_info Pointer to the returned domain controller information
1551 * @return #wbcErr
1553 wbcErr wbcCtxLookupDomainController(struct wbcContext *ctx,
1554 const char *domain,
1555 uint32_t flags,
1556 struct wbcDomainControllerInfo **dc_info);
1559 * @brief Enumerate the domain trusts known by Winbind
1561 * @param domain Name of the domain to query for a DC
1562 * @param flags Bit flags used to control the domain location query
1563 * @param *dc_info Pointer to the returned domain controller information
1565 * @return #wbcErr
1567 wbcErr wbcLookupDomainController(const char *domain,
1568 uint32_t flags,
1569 struct wbcDomainControllerInfo **dc_info);
1572 * @brief Get extended domain controller information
1574 * @param *ctx wbclient Context
1575 * @param domain Name of the domain to query for a DC
1576 * @param guid Guid of the domain to query for a DC
1577 * @param site Site of the domain to query for a DC
1578 * @param flags Bit flags used to control the domain location query
1579 * @param *dc_info Pointer to the returned extended domain controller information
1581 * @return #wbcErr
1583 wbcErr wbcCtxLookupDomainControllerEx(struct wbcContext *ctx,
1584 const char *domain,
1585 struct wbcGuid *guid,
1586 const char *site,
1587 uint32_t flags,
1588 struct wbcDomainControllerInfoEx **dc_info);
1591 * @brief Get extended domain controller information
1593 * @param domain Name of the domain to query for a DC
1594 * @param guid Guid of the domain to query for a DC
1595 * @param site Site of the domain to query for a DC
1596 * @param flags Bit flags used to control the domain location query
1597 * @param *dc_info Pointer to the returned extended domain controller information
1599 * @return #wbcErr
1601 wbcErr wbcLookupDomainControllerEx(const char *domain,
1602 struct wbcGuid *guid,
1603 const char *site,
1604 uint32_t flags,
1605 struct wbcDomainControllerInfoEx **dc_info);
1607 /**********************************************************
1608 * Athenticate functions
1609 **********************************************************/
1612 * @brief Authenticate a username/password pair
1614 * @param *ctx wbclient Context
1615 * @param username Name of user to authenticate
1616 * @param password Clear text password os user
1618 * @return #wbcErr
1620 wbcErr wbcCtxAuthenticateUser(struct wbcContext *ctx,
1621 const char *username,
1622 const char *password);
1625 * @brief Authenticate a username/password pair
1627 * @param username Name of user to authenticate
1628 * @param password Clear text password os user
1630 * @return #wbcErr
1632 wbcErr wbcAuthenticateUser(const char *username,
1633 const char *password);
1636 * @brief Authenticate with more detailed information
1638 * @param *ctx wbclient Context
1639 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1640 * is not supported yet
1641 * @param info Output details on WBC_ERR_SUCCESS
1642 * @param error Output details on WBC_ERR_AUTH_ERROR
1644 * @return #wbcErr
1646 wbcErr wbcCtxAuthenticateUserEx(struct wbcContext *ctx,
1647 const struct wbcAuthUserParams *params,
1648 struct wbcAuthUserInfo **info,
1649 struct wbcAuthErrorInfo **error);
1652 * @brief Authenticate with more detailed information
1654 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1655 * is not supported yet
1656 * @param info Output details on WBC_ERR_SUCCESS
1657 * @param error Output details on WBC_ERR_AUTH_ERROR
1659 * @return #wbcErr
1661 wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
1662 struct wbcAuthUserInfo **info,
1663 struct wbcAuthErrorInfo **error);
1666 * @brief Logon a User
1668 * @param[in] *ctx wbclient Context
1669 * @param[in] params Pointer to a wbcLogonUserParams structure
1670 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1671 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1672 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1674 * @return #wbcErr
1676 wbcErr wbcCtxLogonUser(struct wbcContext *ctx,
1677 const struct wbcLogonUserParams *params,
1678 struct wbcLogonUserInfo **info,
1679 struct wbcAuthErrorInfo **error,
1680 struct wbcUserPasswordPolicyInfo **policy);
1683 * @brief Logon a User
1685 * @param[in] params Pointer to a wbcLogonUserParams structure
1686 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1687 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1688 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1690 * @return #wbcErr
1692 wbcErr wbcLogonUser(const struct wbcLogonUserParams *params,
1693 struct wbcLogonUserInfo **info,
1694 struct wbcAuthErrorInfo **error,
1695 struct wbcUserPasswordPolicyInfo **policy);
1698 * @brief Trigger a logoff notification to Winbind for a specific user
1700 * @param *ctx wbclient Context
1701 * @param username Name of user to remove from Winbind's list of
1702 * logged on users.
1703 * @param uid Uid assigned to the username
1704 * @param ccfilename Absolute path to the Krb5 credentials cache to
1705 * be removed
1707 * @return #wbcErr
1709 wbcErr wbcCtxLogoffUser(struct wbcContext *ctx,
1710 const char *username, uid_t uid,
1711 const char *ccfilename);
1714 * @brief Trigger a logoff notification to Winbind for a specific user
1716 * @param username Name of user to remove from Winbind's list of
1717 * logged on users.
1718 * @param uid Uid assigned to the username
1719 * @param ccfilename Absolute path to the Krb5 credentials cache to
1720 * be removed
1722 * @return #wbcErr
1724 wbcErr wbcLogoffUser(const char *username,
1725 uid_t uid,
1726 const char *ccfilename);
1729 * @brief Trigger an extended logoff notification to Winbind for a specific user
1731 * @param *ctx wbclient Context
1732 * @param params A wbcLogoffUserParams structure
1733 * @param error User output details on error
1735 * @return #wbcErr
1737 wbcErr wbcCtxLogoffUserEx(struct wbcContext *ctx,
1738 const struct wbcLogoffUserParams *params,
1739 struct wbcAuthErrorInfo **error);
1742 * @brief Trigger an extended logoff notification to Winbind for a specific user
1744 * @param params A wbcLogoffUserParams structure
1745 * @param error User output details on error
1747 * @return #wbcErr
1749 wbcErr wbcLogoffUserEx(const struct wbcLogoffUserParams *params,
1750 struct wbcAuthErrorInfo **error);
1753 * @brief Change a password for a user
1755 * @param *ctx wbclient Context
1756 * @param username Name of user to authenticate
1757 * @param old_password Old clear text password of user
1758 * @param new_password New clear text password of user
1760 * @return #wbcErr
1762 wbcErr wbcCtxChangeUserPassword(struct wbcContext *ctx,
1763 const char *username,
1764 const char *old_password,
1765 const char *new_password);
1768 * @brief Change a password for a user
1770 * @param username Name of user to authenticate
1771 * @param old_password Old clear text password of user
1772 * @param new_password New clear text password of user
1774 * @return #wbcErr
1776 wbcErr wbcChangeUserPassword(const char *username,
1777 const char *old_password,
1778 const char *new_password);
1781 * @brief Change a password for a user with more detailed information upon
1782 * failure
1784 * @param *ctx wbclient Context
1785 * @param params Input parameters
1786 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1787 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1788 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1790 * @return #wbcErr
1792 wbcErr wbcCtxChangeUserPasswordEx(struct wbcContext *ctx,
1793 const struct wbcChangePasswordParams *params,
1794 struct wbcAuthErrorInfo **error,
1795 enum wbcPasswordChangeRejectReason *reject_reason,
1796 struct wbcUserPasswordPolicyInfo **policy);
1799 * @brief Change a password for a user with more detailed information upon
1800 * failure
1802 * @param params Input parameters
1803 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1804 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1805 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1807 * @return #wbcErr
1809 wbcErr wbcChangeUserPasswordEx(const struct wbcChangePasswordParams *params,
1810 struct wbcAuthErrorInfo **error,
1811 enum wbcPasswordChangeRejectReason *reject_reason,
1812 struct wbcUserPasswordPolicyInfo **policy);
1815 * @brief Authenticate a user with cached credentials
1817 * @param *ctx wbclient Context
1818 * @param *params Pointer to a wbcCredentialCacheParams structure
1819 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1820 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1822 * @return #wbcErr
1824 wbcErr wbcCtxCredentialCache(struct wbcContext *ctx,
1825 struct wbcCredentialCacheParams *params,
1826 struct wbcCredentialCacheInfo **info,
1827 struct wbcAuthErrorInfo **error);
1830 * @brief Authenticate a user with cached credentials
1832 * @param *params Pointer to a wbcCredentialCacheParams structure
1833 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1834 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1836 * @return #wbcErr
1838 wbcErr wbcCredentialCache(struct wbcCredentialCacheParams *params,
1839 struct wbcCredentialCacheInfo **info,
1840 struct wbcAuthErrorInfo **error);
1843 * @brief Save a password with winbind for doing wbcCredentialCache() later
1845 * @param *ctx wbclient Context
1846 * @param *user Username
1847 * @param *password Password
1849 * @return #wbcErr
1851 wbcErr wbcCtxCredentialSave(struct wbcContext *ctx,
1852 const char *user, const char *password);
1855 * @brief Save a password with winbind for doing wbcCredentialCache() later
1857 * @param *user Username
1858 * @param *password Password
1860 * @return #wbcErr
1862 wbcErr wbcCredentialSave(const char *user, const char *password);
1864 /**********************************************************
1865 * Resolve functions
1866 **********************************************************/
1869 * @brief Resolve a NetbiosName via WINS
1871 * @param *ctx wbclient Context
1872 * @param name Name to resolve
1873 * @param *ip Pointer to the ip address string
1875 * @return #wbcErr
1877 wbcErr wbcCtxResolveWinsByName(struct wbcContext *ctx,
1878 const char *name, char **ip);
1881 * @brief Resolve a NetbiosName via WINS
1883 * @param name Name to resolve
1884 * @param *ip Pointer to the ip address string
1886 * @return #wbcErr
1888 wbcErr wbcResolveWinsByName(const char *name, char **ip);
1891 * @brief Resolve an IP address via WINS into a NetbiosName
1893 * @param *ctx wbclient Context
1894 * @param ip The ip address string
1895 * @param *name Pointer to the name
1897 * @return #wbcErr
1900 wbcErr wbcCtxResolveWinsByIP(struct wbcContext *ctx,
1901 const char *ip, char **name);
1904 * @brief Resolve an IP address via WINS into a NetbiosName
1906 * @param ip The ip address string
1907 * @param *name Pointer to the name
1909 * @return #wbcErr
1912 wbcErr wbcResolveWinsByIP(const char *ip, char **name);
1914 /**********************************************************
1915 * Trusted domain functions
1916 **********************************************************/
1919 * @brief Trigger a verification of the trust credentials of a specific domain
1921 * @param *ctx wbclient Context
1922 * @param *domain The name of the domain.
1923 * @param error Output details on WBC_ERR_AUTH_ERROR
1925 * @return #wbcErr
1927 wbcErr wbcCtxCheckTrustCredentials(struct wbcContext *ctx, const char *domain,
1928 struct wbcAuthErrorInfo **error);
1931 * @brief Trigger a verification of the trust credentials of a specific domain
1933 * @param *domain The name of the domain.
1934 * @param error Output details on WBC_ERR_AUTH_ERROR
1936 * @return #wbcErr
1938 wbcErr wbcCheckTrustCredentials(const char *domain,
1939 struct wbcAuthErrorInfo **error);
1942 * @brief Trigger a change of the trust credentials for a specific domain
1944 * @param *ctx wbclient Context
1945 * @param *domain The name of the domain.
1946 * @param error Output details on WBC_ERR_AUTH_ERROR
1948 * @return #wbcErr
1950 wbcErr wbcCtxChangeTrustCredentials(struct wbcContext *ctx, const char *domain,
1951 struct wbcAuthErrorInfo **error);
1954 * @brief Trigger a change of the trust credentials for a specific domain
1956 * @param *domain The name of the domain.
1957 * @param error Output details on WBC_ERR_AUTH_ERROR
1959 * @return #wbcErr
1961 wbcErr wbcChangeTrustCredentials(const char *domain,
1962 struct wbcAuthErrorInfo **error);
1965 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1966 * version of wbcCheckTrustCredentials
1968 * @param *ctx wbclient Context
1969 * @param *domain The name of the domain, only NULL for the default domain is
1970 * supported yet. Other values than NULL will result in
1971 * WBC_ERR_NOT_IMPLEMENTED.
1972 * @param error Output details on WBC_ERR_AUTH_ERROR
1974 * @return #wbcErr
1976 wbcErr wbcCtxPingDc(struct wbcContext *ctx, const char *domain,
1977 struct wbcAuthErrorInfo **error);
1980 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1981 * version of wbcCheckTrustCredentials
1983 * @param *domain The name of the domain, only NULL for the default domain is
1984 * supported yet. Other values than NULL will result in
1985 * WBC_ERR_NOT_IMPLEMENTED.
1986 * @param error Output details on WBC_ERR_AUTH_ERROR
1988 * @return #wbcErr
1990 wbcErr wbcPingDc(const char *domain, struct wbcAuthErrorInfo **error);
1993 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1994 * version of wbcCheckTrustCredentials
1996 * @param *ctx wbclient Context
1997 * @param *domain The name of the domain, only NULL for the default domain is
1998 * supported yet. Other values than NULL will result in
1999 * WBC_ERR_NOT_IMPLEMENTED.
2000 * @param error Output details on WBC_ERR_AUTH_ERROR
2001 * @param dcname DC that was attempted to ping
2003 * @return #wbcErr
2005 wbcErr wbcCtxPingDc2(struct wbcContext *ctx, const char *domain,
2006 struct wbcAuthErrorInfo **error,
2007 char **dcname);
2010 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
2011 * version of wbcCheckTrustCredentials
2013 * @param *domain The name of the domain, only NULL for the default domain is
2014 * supported yet. Other values than NULL will result in
2015 * WBC_ERR_NOT_IMPLEMENTED.
2016 * @param error Output details on WBC_ERR_AUTH_ERROR
2017 * @param dcname DC that was attempted to ping
2019 * @return #wbcErr
2021 wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
2022 char **dcname);
2024 /**********************************************************
2025 * Helper functions
2026 **********************************************************/
2029 * @brief Initialize a named blob and add to list of blobs
2031 * @param[in,out] num_blobs Pointer to the number of blobs
2032 * @param[in,out] blobs Pointer to an array of blobs
2033 * @param[in] name Name of the new named blob
2034 * @param[in] flags Flags of the new named blob
2035 * @param[in] data Blob data of new blob
2036 * @param[in] length Blob data length of new blob
2038 * @return #wbcErr
2040 wbcErr wbcAddNamedBlob(size_t *num_blobs,
2041 struct wbcNamedBlob **blobs,
2042 const char *name,
2043 uint32_t flags,
2044 uint8_t *data,
2045 size_t length);
2047 #endif /* _WBCLIENT_H */