2 Unix SMB/CIFS implementation.
6 Copyright (C) Gerald (Jerry) Carter 2007
7 Copyright (C) Volker Lendecke 2009
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 3 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 /* Define error types */
32 * @brief Status codes returned from wbc functions
36 WBC_ERR_SUCCESS
= 0, /**< Successful completion **/
37 WBC_ERR_NOT_IMPLEMENTED
,/**< Function not implemented **/
38 WBC_ERR_UNKNOWN_FAILURE
,/**< General failure **/
39 WBC_ERR_NO_MEMORY
, /**< Memory allocation error **/
40 WBC_ERR_INVALID_SID
, /**< Invalid SID format **/
41 WBC_ERR_INVALID_PARAM
, /**< An Invalid parameter was supplied **/
42 WBC_ERR_WINBIND_NOT_AVAILABLE
, /**< Winbind daemon is not available **/
43 WBC_ERR_DOMAIN_NOT_FOUND
, /**< Domain is not trusted or cannot be found **/
44 WBC_ERR_INVALID_RESPONSE
, /**< Winbind returned an invalid response **/
45 WBC_ERR_NSS_ERROR
, /**< NSS_STATUS error **/
46 WBC_ERR_AUTH_ERROR
, /**< Authentication failed **/
47 WBC_ERR_UNKNOWN_USER
, /**< User account cannot be found */
48 WBC_ERR_UNKNOWN_GROUP
, /**< Group account cannot be found */
49 WBC_ERR_PWD_CHANGE_FAILED
/**< Password Change has failed */
52 typedef enum _wbcErrType wbcErr
;
54 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
56 const char *wbcErrorString(wbcErr error
);
59 * @brief Some useful details about the wbclient library
61 * 0.1: Initial version
62 * 0.2: Added wbcRemoveUidMapping()
63 * Added wbcRemoveGidMapping()
64 * 0.3: Added wbcGetpwsid()
65 * Added wbcGetSidAliases()
66 * 0.4: Added wbcSidTypeString()
67 * 0.5: Added wbcChangeTrustCredentials()
68 * 0.6: Made struct wbcInterfaceDetails char* members non-const
69 * 0.7: Added wbcSidToStringBuf()
70 * 0.8: Added wbcSidsToUnixIds() and wbcLookupSids()
71 * 0.9: Added support for WBC_ID_TYPE_BOTH
72 * 0.10: Added wbcPingDc2()
73 * 0.11: Extended wbcAuthenticateUserEx to provide PAC parsing
75 #define WBCLIENT_MAJOR_VERSION 0
76 #define WBCLIENT_MINOR_VERSION 11
77 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
78 struct wbcLibraryDetails
{
79 uint16_t major_version
;
80 uint16_t minor_version
;
81 const char *vendor_version
;
85 * @brief Some useful details about the running winbindd
88 struct wbcInterfaceDetails
{
89 uint32_t interface_version
;
90 char *winbind_version
;
91 char winbind_separator
;
98 * Data types used by the Winbind Client API
101 #ifndef WBC_MAXSUBAUTHS
102 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
106 * @brief Windows Security Identifier
110 struct wbcDomainSid
{
114 uint32_t sub_auths
[WBC_MAXSUBAUTHS
];
118 * @brief Security Identifier type
122 WBC_SID_NAME_USE_NONE
=0,
124 WBC_SID_NAME_DOM_GRP
=2,
125 WBC_SID_NAME_DOMAIN
=3,
126 WBC_SID_NAME_ALIAS
=4,
127 WBC_SID_NAME_WKN_GRP
=5,
128 WBC_SID_NAME_DELETED
=6,
129 WBC_SID_NAME_INVALID
=7,
130 WBC_SID_NAME_UNKNOWN
=8,
131 WBC_SID_NAME_COMPUTER
=9
135 * @brief Security Identifier with attributes
138 struct wbcSidWithAttr
{
139 struct wbcDomainSid sid
;
143 /* wbcSidWithAttr->attributes */
145 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
146 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
147 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
148 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
149 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
150 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
151 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
154 * @brief Windows GUID
161 uint16_t time_hi_and_version
;
162 uint8_t clock_seq
[2];
167 * @brief Domain Information
170 struct wbcDomainInfo
{
173 struct wbcDomainSid sid
;
174 uint32_t domain_flags
;
175 uint32_t trust_flags
;
179 /* wbcDomainInfo->domain_flags */
181 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
182 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
183 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
184 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
185 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
187 /* wbcDomainInfo->trust_flags */
189 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
190 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
191 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
193 /* wbcDomainInfo->trust_type */
195 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
196 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
197 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
198 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
201 * @brief Generic Blob
213 struct wbcNamedBlob
{
220 * @brief Auth User Parameters
223 struct wbcAuthUserParams
{
224 const char *account_name
;
225 const char *domain_name
;
226 const char *workstation_name
;
230 uint32_t parameter_control
;
232 enum wbcAuthUserLevel
{
233 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
234 WBC_AUTH_USER_LEVEL_HASH
= 2,
235 WBC_AUTH_USER_LEVEL_RESPONSE
= 3,
236 WBC_AUTH_USER_LEVEL_PAC
= 4
239 const char *plaintext
;
245 uint8_t challenge
[8];
256 * @brief Logon User Parameters
259 struct wbcLogonUserParams
{
260 const char *username
;
261 const char *password
;
263 struct wbcNamedBlob
*blobs
;
267 * @brief ChangePassword Parameters
270 struct wbcChangePasswordParams
{
271 const char *account_name
;
272 const char *domain_name
;
276 enum wbcChangePasswordLevel
{
277 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
278 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
282 const char *plaintext
;
284 uint32_t old_nt_hash_enc_length
;
285 uint8_t *old_nt_hash_enc_data
;
286 uint32_t old_lm_hash_enc_length
;
287 uint8_t *old_lm_hash_enc_data
;
291 const char *plaintext
;
301 /* wbcAuthUserParams->parameter_control */
303 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
304 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
305 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
306 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
307 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
308 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
310 /* wbcAuthUserParams->flags */
312 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
315 * @brief Auth User Information
317 * Some of the strings are maybe NULL
320 struct wbcAuthUserInfo
{
324 char *user_principal
;
327 char *dns_domain_name
;
330 uint8_t user_session_key
[16];
331 uint8_t lm_session_key
[8];
333 uint16_t logon_count
;
334 uint16_t bad_password_count
;
337 uint64_t logoff_time
;
338 uint64_t kickoff_time
;
339 uint64_t pass_last_set_time
;
340 uint64_t pass_can_change_time
;
341 uint64_t pass_must_change_time
;
346 char *home_directory
;
350 * the 1st one is the account sid
351 * the 2nd one is the primary_group sid
352 * followed by the rest of the groups
355 struct wbcSidWithAttr
*sids
;
359 * @brief Logon User Information
361 * Some of the strings are maybe NULL
364 struct wbcLogonUserInfo
{
365 struct wbcAuthUserInfo
*info
;
367 struct wbcNamedBlob
*blobs
;
370 /* wbcAuthUserInfo->user_flags */
372 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
373 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
374 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
375 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
376 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
377 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
378 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
379 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
380 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
381 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
382 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
384 /* wbcAuthUserInfo->acct_flags */
386 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
387 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
388 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
389 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
390 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
391 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
392 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
393 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
394 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
395 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
396 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
397 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
398 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
399 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
400 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
401 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
402 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
403 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
404 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
406 struct wbcAuthErrorInfo
{
410 char *display_string
;
414 * @brief User Password Policy Information
417 /* wbcUserPasswordPolicyInfo->password_properties */
419 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
420 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
421 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
422 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
423 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
424 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
426 struct wbcUserPasswordPolicyInfo
{
427 uint32_t min_length_password
;
428 uint32_t password_history
;
429 uint32_t password_properties
;
431 uint64_t min_passwordage
;
435 * @brief Change Password Reject Reason
438 enum wbcPasswordChangeRejectReason
{
439 WBC_PWD_CHANGE_NO_ERROR
=0,
440 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
=1,
441 WBC_PWD_CHANGE_PWD_IN_HISTORY
=2,
442 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD
=3,
443 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD
=4,
444 WBC_PWD_CHANGE_NOT_COMPLEX
=5,
445 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT
=6,
446 WBC_PWD_CHANGE_FAILED_BY_FILTER
=7,
447 WBC_PWD_CHANGE_PASSWORD_TOO_LONG
=8
450 /* Note: this defines exist for compatibility reasons with existing code */
451 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
452 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
453 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
454 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
457 * @brief Logoff User Parameters
460 struct wbcLogoffUserParams
{
461 const char *username
;
463 struct wbcNamedBlob
*blobs
;
466 /** @brief Credential cache log-on parameters
470 struct wbcCredentialCacheParams
{
471 const char *account_name
;
472 const char *domain_name
;
473 enum wbcCredentialCacheLevel
{
474 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
477 struct wbcNamedBlob
*blobs
;
481 /** @brief Info returned by credential cache auth
485 struct wbcCredentialCacheInfo
{
487 struct wbcNamedBlob
*blobs
;
491 * DomainControllerInfo struct
493 struct wbcDomainControllerInfo
{
498 * DomainControllerInfoEx struct
500 struct wbcDomainControllerInfoEx
{
502 const char *dc_address
;
503 uint16_t dc_address_type
;
504 struct wbcGuid
*domain_guid
;
505 const char *domain_name
;
506 const char *forest_name
;
508 const char *dc_site_name
;
509 const char *client_site_name
;
512 /**********************************************************
514 **********************************************************/
517 * @brief Free library allocated memory
519 * @param * Pointer to free
523 void wbcFreeMemory(void*);
527 * Utility functions for dealing with SIDs
531 * @brief Get a string representation of the SID type
533 * @param type type of the SID
535 * @return string representation of the SID type
537 const char* wbcSidTypeString(enum wbcSidType type
);
539 #define WBC_SID_STRING_BUFLEN (15*11+25)
542 * @brief Print a sid into a buffer
544 * @param sid Binary Security Identifier
545 * @param buf Target buffer
546 * @param buflen Target buffer length
548 * @return Resulting string length.
550 int wbcSidToStringBuf(const struct wbcDomainSid
*sid
, char *buf
, int buflen
);
553 * @brief Convert a binary SID to a character string
555 * @param sid Binary Security Identifier
556 * @param **sid_string Resulting character string
560 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
564 * @brief Convert a character string to a binary SID
566 * @param *sid_string Character string in the form of S-...
567 * @param sid Resulting binary SID
571 wbcErr
wbcStringToSid(const char *sid_string
,
572 struct wbcDomainSid
*sid
);
575 * Utility functions for dealing with GUIDs
579 * @brief Convert a binary GUID to a character string
581 * @param guid Binary Guid
582 * @param **guid_string Resulting character string
586 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
590 * @brief Convert a character string to a binary GUID
592 * @param *guid_string Character string
593 * @param guid Resulting binary GUID
597 wbcErr
wbcStringToGuid(const char *guid_string
,
598 struct wbcGuid
*guid
);
601 * @brief Ping winbindd to see if the daemon is running
605 wbcErr
wbcPing(void);
607 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
609 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
611 /**********************************************************
612 * Name/SID conversion
613 **********************************************************/
616 * @brief Convert a domain and name to SID
618 * @param dom_name Domain name (possibly "")
619 * @param name User or group name
620 * @param *sid Pointer to the resolved domain SID
621 * @param *name_type Pointer to the SID type
625 wbcErr
wbcLookupName(const char *dom_name
,
627 struct wbcDomainSid
*sid
,
628 enum wbcSidType
*name_type
);
631 * @brief Convert a SID to a domain and name
633 * @param *sid Pointer to the domain SID to be resolved
634 * @param domain Resolved Domain name (possibly "")
635 * @param name Resolved User or group name
636 * @param *name_type Pointer to the resolved SID type
640 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
643 enum wbcSidType
*name_type
);
645 struct wbcTranslatedName
{
646 enum wbcSidType type
;
651 wbcErr
wbcLookupSids(const struct wbcDomainSid
*sids
, int num_sids
,
652 struct wbcDomainInfo
**domains
, int *num_domains
,
653 struct wbcTranslatedName
**names
);
656 * @brief Translate a collection of RIDs within a domain to names
658 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
661 const char **domain_name
,
663 enum wbcSidType
**types
);
666 * @brief Get the groups a user belongs to
668 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
669 bool domain_groups_only
,
671 struct wbcDomainSid
**sids
);
674 * @brief Get alias membership for sids
676 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
677 struct wbcDomainSid
*sids
,
679 uint32_t **alias_rids
,
680 uint32_t *num_alias_rids
);
685 wbcErr
wbcListUsers(const char *domain_name
,
687 const char ***users
);
690 * @brief Lists Groups
692 wbcErr
wbcListGroups(const char *domain_name
,
693 uint32_t *num_groups
,
694 const char ***groups
);
696 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
699 enum wbcSidType
*pname_type
);
701 /**********************************************************
702 * SID/uid/gid Mappings
703 **********************************************************/
706 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
708 * @param *sid Pointer to the domain SID to be resolved
709 * @param *puid Pointer to the resolved uid_t value
714 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
718 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
720 * @param *sid Pointer to the domain SID to be resolved
721 * @param *puid Pointer to the resolved uid_t value
726 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
730 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
732 * @param uid Unix uid to be resolved
733 * @param *sid Pointer to the resolved domain SID
738 wbcErr
wbcUidToSid(uid_t uid
,
739 struct wbcDomainSid
*sid
);
742 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
744 * @param uid Unix uid to be resolved
745 * @param *sid Pointer to the resolved domain SID
750 wbcErr
wbcQueryUidToSid(uid_t uid
,
751 struct wbcDomainSid
*sid
);
754 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
756 * @param *sid Pointer to the domain SID to be resolved
757 * @param *pgid Pointer to the resolved gid_t value
762 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
766 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
768 * @param *sid Pointer to the domain SID to be resolved
769 * @param *pgid Pointer to the resolved gid_t value
774 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
778 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
780 * @param gid Unix gid to be resolved
781 * @param *sid Pointer to the resolved domain SID
786 wbcErr
wbcGidToSid(gid_t gid
,
787 struct wbcDomainSid
*sid
);
790 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
792 * @param gid Unix gid to be resolved
793 * @param *sid Pointer to the resolved domain SID
798 wbcErr
wbcQueryGidToSid(gid_t gid
,
799 struct wbcDomainSid
*sid
);
802 WBC_ID_TYPE_NOT_SPECIFIED
,
808 union wbcUnixIdContainer
{
815 union wbcUnixIdContainer id
;
819 * @brief Convert a list of sids to unix ids
821 * @param sids Pointer to an array of SIDs to convert
822 * @param num_sids Number of SIDs
823 * @param ids Preallocated output array for translated IDs
828 wbcErr
wbcSidsToUnixIds(const struct wbcDomainSid
*sids
, uint32_t num_sids
,
829 struct wbcUnixId
*ids
);
832 * @brief Obtain a new uid from Winbind
834 * @param *puid *pointer to the allocated uid
838 wbcErr
wbcAllocateUid(uid_t
*puid
);
841 * @brief Obtain a new gid from Winbind
843 * @param *pgid Pointer to the allocated gid
847 wbcErr
wbcAllocateGid(gid_t
*pgid
);
850 * @brief Set an user id mapping
852 * @param uid Uid of the desired mapping.
853 * @param *sid Pointer to the sid of the diresired mapping.
857 * @deprecated This method is not impemented any more and should
858 * be removed in the next major version change.
860 wbcErr
wbcSetUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
863 * @brief Set a group id mapping
865 * @param gid Gid of the desired mapping.
866 * @param *sid Pointer to the sid of the diresired mapping.
870 * @deprecated This method is not impemented any more and should
871 * be removed in the next major version change.
873 wbcErr
wbcSetGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
876 * @brief Remove a user id mapping
878 * @param uid Uid of the mapping to remove.
879 * @param *sid Pointer to the sid of the mapping to remove.
883 * @deprecated This method is not impemented any more and should
884 * be removed in the next major version change.
886 wbcErr
wbcRemoveUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
889 * @brief Remove a group id mapping
891 * @param gid Gid of the mapping to remove.
892 * @param *sid Pointer to the sid of the mapping to remove.
896 * @deprecated This method is not impemented any more and should
897 * be removed in the next major version change.
899 wbcErr
wbcRemoveGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
902 * @brief Set the highwater mark for allocated uids.
904 * @param uid_hwm The new uid highwater mark value
908 * @deprecated This method is not impemented any more and should
909 * be removed in the next major version change.
911 wbcErr
wbcSetUidHwm(uid_t uid_hwm
);
914 * @brief Set the highwater mark for allocated gids.
916 * @param gid_hwm The new gid highwater mark value
920 * @deprecated This method is not impemented any more and should
921 * be removed in the next major version change.
923 wbcErr
wbcSetGidHwm(gid_t gid_hwm
);
925 /**********************************************************
926 * NSS Lookup User/Group details
927 **********************************************************/
930 * @brief Fill in a struct passwd* for a domain user based
933 * @param *name Username to lookup
934 * @param **pwd Pointer to resulting struct passwd* from the query.
938 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
941 * @brief Fill in a struct passwd* for a domain user based
944 * @param uid Uid to lookup
945 * @param **pwd Pointer to resulting struct passwd* from the query.
949 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
952 * @brief Fill in a struct passwd* for a domain user based
955 * @param sid Sid to lookup
956 * @param **pwd Pointer to resulting struct passwd* from the query.
960 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
963 * @brief Fill in a struct passwd* for a domain user based
966 * @param *name Username to lookup
967 * @param **grp Pointer to resulting struct group* from the query.
971 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
974 * @brief Fill in a struct passwd* for a domain user based
977 * @param gid Uid to lookup
978 * @param **grp Pointer to resulting struct group* from the query.
982 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
985 * @brief Reset the passwd iterator
989 wbcErr
wbcSetpwent(void);
992 * @brief Close the passwd iterator
996 wbcErr
wbcEndpwent(void);
999 * @brief Return the next struct passwd* entry from the pwent iterator
1001 * @param **pwd Pointer to resulting struct passwd* from the query.
1005 wbcErr
wbcGetpwent(struct passwd
**pwd
);
1008 * @brief Reset the group iterator
1012 wbcErr
wbcSetgrent(void);
1015 * @brief Close the group iterator
1019 wbcErr
wbcEndgrent(void);
1022 * @brief Return the next struct group* entry from the pwent iterator
1024 * @param **grp Pointer to resulting struct group* from the query.
1028 wbcErr
wbcGetgrent(struct group
**grp
);
1031 * @brief Return the next struct group* entry from the pwent iterator
1033 * This is similar to #wbcGetgrent, just that the member list is empty
1035 * @param **grp Pointer to resulting struct group* from the query.
1039 wbcErr
wbcGetgrlist(struct group
**grp
);
1042 * @brief Return the unix group array belonging to the given user
1044 * @param *account The given user name
1045 * @param *num_groups Number of elements returned in the groups array
1046 * @param **_groups Pointer to resulting gid_t array.
1050 wbcErr
wbcGetGroups(const char *account
,
1051 uint32_t *num_groups
,
1055 /**********************************************************
1056 * Lookup Domain information
1057 **********************************************************/
1060 * @brief Lookup the current status of a trusted domain
1062 * @param domain The domain to query
1064 * @param dinfo A pointer to store the returned domain_info struct.
1068 wbcErr
wbcDomainInfo(const char *domain
,
1069 struct wbcDomainInfo
**dinfo
);
1072 * @brief Lookup the currently contacted DCs
1074 * @param domain The domain to query
1076 * @param num_dcs Number of DCs currently known
1077 * @param dc_names Names of the currently known DCs
1078 * @param dc_ips IP addresses of the currently known DCs
1082 wbcErr
wbcDcInfo(const char *domain
, size_t *num_dcs
,
1083 const char ***dc_names
, const char ***dc_ips
);
1086 * @brief Enumerate the domain trusts known by Winbind
1088 * @param **domains Pointer to the allocated domain list array
1089 * @param *num_domains Pointer to number of domains returned
1093 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
1094 size_t *num_domains
);
1096 /* Flags for wbcLookupDomainController */
1098 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1099 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1100 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1101 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1102 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1103 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1104 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1105 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1106 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1107 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1108 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1109 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1110 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1111 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1112 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1113 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1114 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1115 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1116 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1119 * @brief Enumerate the domain trusts known by Winbind
1121 * @param domain Name of the domain to query for a DC
1122 * @param flags Bit flags used to control the domain location query
1123 * @param *dc_info Pointer to the returned domain controller information
1127 wbcErr
wbcLookupDomainController(const char *domain
,
1129 struct wbcDomainControllerInfo
**dc_info
);
1132 * @brief Get extended domain controller information
1134 * @param domain Name of the domain to query for a DC
1135 * @param guid Guid of the domain to query for a DC
1136 * @param site Site of the domain to query for a DC
1137 * @param flags Bit flags used to control the domain location query
1138 * @param *dc_info Pointer to the returned extended domain controller information
1142 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1143 struct wbcGuid
*guid
,
1146 struct wbcDomainControllerInfoEx
**dc_info
);
1148 /**********************************************************
1149 * Athenticate functions
1150 **********************************************************/
1153 * @brief Authenticate a username/password pair
1155 * @param username Name of user to authenticate
1156 * @param password Clear text password os user
1160 wbcErr
wbcAuthenticateUser(const char *username
,
1161 const char *password
);
1164 * @brief Authenticate with more detailed information
1166 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1167 * is not supported yet
1168 * @param info Output details on WBC_ERR_SUCCESS
1169 * @param error Output details on WBC_ERR_AUTH_ERROR
1173 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1174 struct wbcAuthUserInfo
**info
,
1175 struct wbcAuthErrorInfo
**error
);
1178 * @brief Logon a User
1180 * @param[in] params Pointer to a wbcLogonUserParams structure
1181 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1182 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1183 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1187 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1188 struct wbcLogonUserInfo
**info
,
1189 struct wbcAuthErrorInfo
**error
,
1190 struct wbcUserPasswordPolicyInfo
**policy
);
1193 * @brief Trigger a logoff notification to Winbind for a specific user
1195 * @param username Name of user to remove from Winbind's list of
1197 * @param uid Uid assigned to the username
1198 * @param ccfilename Absolute path to the Krb5 credentials cache to
1203 wbcErr
wbcLogoffUser(const char *username
,
1205 const char *ccfilename
);
1208 * @brief Trigger an extended logoff notification to Winbind for a specific user
1210 * @param params A wbcLogoffUserParams structure
1211 * @param error User output details on error
1215 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1216 struct wbcAuthErrorInfo
**error
);
1219 * @brief Change a password for a user
1221 * @param username Name of user to authenticate
1222 * @param old_password Old clear text password of user
1223 * @param new_password New clear text password of user
1227 wbcErr
wbcChangeUserPassword(const char *username
,
1228 const char *old_password
,
1229 const char *new_password
);
1232 * @brief Change a password for a user with more detailed information upon
1235 * @param params Input parameters
1236 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1237 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1238 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1242 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1243 struct wbcAuthErrorInfo
**error
,
1244 enum wbcPasswordChangeRejectReason
*reject_reason
,
1245 struct wbcUserPasswordPolicyInfo
**policy
);
1248 * @brief Authenticate a user with cached credentials
1250 * @param *params Pointer to a wbcCredentialCacheParams structure
1251 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1252 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1256 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1257 struct wbcCredentialCacheInfo
**info
,
1258 struct wbcAuthErrorInfo
**error
);
1261 * @brief Save a password with winbind for doing wbcCredentialCache() later
1263 * @param *user Username
1264 * @param *password Password
1268 wbcErr
wbcCredentialSave(const char *user
, const char *password
);
1270 /**********************************************************
1272 **********************************************************/
1275 * @brief Resolve a NetbiosName via WINS
1277 * @param name Name to resolve
1278 * @param *ip Pointer to the ip address string
1282 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1285 * @brief Resolve an IP address via WINS into a NetbiosName
1287 * @param ip The ip address string
1288 * @param *name Pointer to the name
1293 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1295 /**********************************************************
1296 * Trusted domain functions
1297 **********************************************************/
1300 * @brief Trigger a verification of the trust credentials of a specific domain
1302 * @param *domain The name of the domain.
1303 * @param error Output details on WBC_ERR_AUTH_ERROR
1307 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1308 struct wbcAuthErrorInfo
**error
);
1311 * @brief Trigger a change of the trust credentials for a specific domain
1313 * @param *domain The name of the domain.
1314 * @param error Output details on WBC_ERR_AUTH_ERROR
1318 wbcErr
wbcChangeTrustCredentials(const char *domain
,
1319 struct wbcAuthErrorInfo
**error
);
1322 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1323 * version of wbcCheckTrustCredentials
1325 * @param *domain The name of the domain, only NULL for the default domain is
1326 * supported yet. Other values than NULL will result in
1327 * WBC_ERR_NOT_IMPLEMENTED.
1328 * @param error Output details on WBC_ERR_AUTH_ERROR
1332 wbcErr
wbcPingDc(const char *domain
, struct wbcAuthErrorInfo
**error
);
1335 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1336 * version of wbcCheckTrustCredentials
1338 * @param *domain The name of the domain, only NULL for the default domain is
1339 * supported yet. Other values than NULL will result in
1340 * WBC_ERR_NOT_IMPLEMENTED.
1341 * @param error Output details on WBC_ERR_AUTH_ERROR
1342 * @param dcname DC that was attempted to ping
1346 wbcErr
wbcPingDc2(const char *domain
, struct wbcAuthErrorInfo
**error
,
1349 /**********************************************************
1351 **********************************************************/
1354 * @brief Initialize a named blob and add to list of blobs
1356 * @param[in,out] num_blobs Pointer to the number of blobs
1357 * @param[in,out] blobs Pointer to an array of blobs
1358 * @param[in] name Name of the new named blob
1359 * @param[in] flags Flags of the new named blob
1360 * @param[in] data Blob data of new blob
1361 * @param[in] length Blob data length of new blob
1365 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1366 struct wbcNamedBlob
**blobs
,
1372 #endif /* _WBCLIENT_H */