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()
72 #define WBCLIENT_MAJOR_VERSION 0
73 #define WBCLIENT_MINOR_VERSION 8
74 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
75 struct wbcLibraryDetails
{
76 uint16_t major_version
;
77 uint16_t minor_version
;
78 const char *vendor_version
;
82 * @brief Some useful details about the running winbindd
85 struct wbcInterfaceDetails
{
86 uint32_t interface_version
;
87 char *winbind_version
;
88 char winbind_separator
;
95 * Data types used by the Winbind Client API
98 #ifndef WBC_MAXSUBAUTHS
99 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
103 * @brief Windows Security Identifier
107 struct wbcDomainSid
{
111 uint32_t sub_auths
[WBC_MAXSUBAUTHS
];
115 * @brief Security Identifier type
119 WBC_SID_NAME_USE_NONE
=0,
121 WBC_SID_NAME_DOM_GRP
=2,
122 WBC_SID_NAME_DOMAIN
=3,
123 WBC_SID_NAME_ALIAS
=4,
124 WBC_SID_NAME_WKN_GRP
=5,
125 WBC_SID_NAME_DELETED
=6,
126 WBC_SID_NAME_INVALID
=7,
127 WBC_SID_NAME_UNKNOWN
=8,
128 WBC_SID_NAME_COMPUTER
=9
132 * @brief Security Identifier with attributes
135 struct wbcSidWithAttr
{
136 struct wbcDomainSid sid
;
140 /* wbcSidWithAttr->attributes */
142 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
143 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
144 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
145 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
146 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
147 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
148 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
151 * @brief Windows GUID
158 uint16_t time_hi_and_version
;
159 uint8_t clock_seq
[2];
164 * @brief Domain Information
167 struct wbcDomainInfo
{
170 struct wbcDomainSid sid
;
171 uint32_t domain_flags
;
172 uint32_t trust_flags
;
176 /* wbcDomainInfo->domain_flags */
178 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
179 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
180 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
181 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
182 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
184 /* wbcDomainInfo->trust_flags */
186 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
187 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
188 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
190 /* wbcDomainInfo->trust_type */
192 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
193 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
194 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
195 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
198 * @brief Auth User Parameters
201 struct wbcAuthUserParams
{
202 const char *account_name
;
203 const char *domain_name
;
204 const char *workstation_name
;
208 uint32_t parameter_control
;
210 enum wbcAuthUserLevel
{
211 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
212 WBC_AUTH_USER_LEVEL_HASH
= 2,
213 WBC_AUTH_USER_LEVEL_RESPONSE
= 3
216 const char *plaintext
;
222 uint8_t challenge
[8];
232 * @brief Generic Blob
244 struct wbcNamedBlob
{
251 * @brief Logon User Parameters
254 struct wbcLogonUserParams
{
255 const char *username
;
256 const char *password
;
258 struct wbcNamedBlob
*blobs
;
262 * @brief ChangePassword Parameters
265 struct wbcChangePasswordParams
{
266 const char *account_name
;
267 const char *domain_name
;
271 enum wbcChangePasswordLevel
{
272 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
273 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
277 const char *plaintext
;
279 uint32_t old_nt_hash_enc_length
;
280 uint8_t *old_nt_hash_enc_data
;
281 uint32_t old_lm_hash_enc_length
;
282 uint8_t *old_lm_hash_enc_data
;
286 const char *plaintext
;
296 /* wbcAuthUserParams->parameter_control */
298 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
299 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
300 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
301 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
302 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
303 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
305 /* wbcAuthUserParams->flags */
307 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
310 * @brief Auth User Information
312 * Some of the strings are maybe NULL
315 struct wbcAuthUserInfo
{
319 char *user_principal
;
322 char *dns_domain_name
;
325 uint8_t user_session_key
[16];
326 uint8_t lm_session_key
[8];
328 uint16_t logon_count
;
329 uint16_t bad_password_count
;
332 uint64_t logoff_time
;
333 uint64_t kickoff_time
;
334 uint64_t pass_last_set_time
;
335 uint64_t pass_can_change_time
;
336 uint64_t pass_must_change_time
;
341 char *home_directory
;
345 * the 1st one is the account sid
346 * the 2nd one is the primary_group sid
347 * followed by the rest of the groups
350 struct wbcSidWithAttr
*sids
;
354 * @brief Logon User Information
356 * Some of the strings are maybe NULL
359 struct wbcLogonUserInfo
{
360 struct wbcAuthUserInfo
*info
;
362 struct wbcNamedBlob
*blobs
;
365 /* wbcAuthUserInfo->user_flags */
367 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
368 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
369 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
370 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
371 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
372 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
373 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
374 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
375 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
376 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
377 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
379 /* wbcAuthUserInfo->acct_flags */
381 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
382 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
383 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
384 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
385 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
386 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
387 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
388 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
389 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
390 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
391 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
392 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
393 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
394 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
395 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
396 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
397 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
398 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
399 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
401 struct wbcAuthErrorInfo
{
405 char *display_string
;
409 * @brief User Password Policy Information
412 /* wbcUserPasswordPolicyInfo->password_properties */
414 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
415 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
416 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
417 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
418 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
419 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
421 struct wbcUserPasswordPolicyInfo
{
422 uint32_t min_length_password
;
423 uint32_t password_history
;
424 uint32_t password_properties
;
426 uint64_t min_passwordage
;
430 * @brief Change Password Reject Reason
433 enum wbcPasswordChangeRejectReason
{
434 WBC_PWD_CHANGE_NO_ERROR
=0,
435 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
=1,
436 WBC_PWD_CHANGE_PWD_IN_HISTORY
=2,
437 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD
=3,
438 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD
=4,
439 WBC_PWD_CHANGE_NOT_COMPLEX
=5,
440 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT
=6,
441 WBC_PWD_CHANGE_FAILED_BY_FILTER
=7,
442 WBC_PWD_CHANGE_PASSWORD_TOO_LONG
=8
445 /* Note: this defines exist for compatibility reasons with existing code */
446 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
447 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
448 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
449 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
452 * @brief Logoff User Parameters
455 struct wbcLogoffUserParams
{
456 const char *username
;
458 struct wbcNamedBlob
*blobs
;
461 /** @brief Credential cache log-on parameters
465 struct wbcCredentialCacheParams
{
466 const char *account_name
;
467 const char *domain_name
;
468 enum wbcCredentialCacheLevel
{
469 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
472 struct wbcNamedBlob
*blobs
;
476 /** @brief Info returned by credential cache auth
480 struct wbcCredentialCacheInfo
{
482 struct wbcNamedBlob
*blobs
;
486 * DomainControllerInfo struct
488 struct wbcDomainControllerInfo
{
493 * DomainControllerInfoEx struct
495 struct wbcDomainControllerInfoEx
{
497 const char *dc_address
;
498 uint16_t dc_address_type
;
499 struct wbcGuid
*domain_guid
;
500 const char *domain_name
;
501 const char *forest_name
;
503 const char *dc_site_name
;
504 const char *client_site_name
;
507 /**********************************************************
509 **********************************************************/
512 * @brief Free library allocated memory
514 * @param * Pointer to free
518 void wbcFreeMemory(void*);
522 * Utility functions for dealing with SIDs
526 * @brief Get a string representation of the SID type
528 * @param type type of the SID
530 * @return string representation of the SID type
532 const char* wbcSidTypeString(enum wbcSidType type
);
534 #define WBC_SID_STRING_BUFLEN (15*11+25)
537 * @brief Print a sid into a buffer
539 * @param sid Binary Security Identifier
540 * @param buf Target buffer
541 * @param buflen Target buffer length
543 * @return Resulting string length.
545 int wbcSidToStringBuf(const struct wbcDomainSid
*sid
, char *buf
, int buflen
);
548 * @brief Convert a binary SID to a character string
550 * @param sid Binary Security Identifier
551 * @param **sid_string Resulting character string
555 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
559 * @brief Convert a character string to a binary SID
561 * @param *sid_string Character string in the form of S-...
562 * @param sid Resulting binary SID
566 wbcErr
wbcStringToSid(const char *sid_string
,
567 struct wbcDomainSid
*sid
);
570 * Utility functions for dealing with GUIDs
574 * @brief Convert a binary GUID to a character string
576 * @param guid Binary Guid
577 * @param **guid_string Resulting character string
581 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
585 * @brief Convert a character string to a binary GUID
587 * @param *guid_string Character string
588 * @param guid Resulting binary GUID
592 wbcErr
wbcStringToGuid(const char *guid_string
,
593 struct wbcGuid
*guid
);
596 * @brief Ping winbindd to see if the daemon is running
600 wbcErr
wbcPing(void);
602 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
604 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
606 /**********************************************************
607 * Name/SID conversion
608 **********************************************************/
611 * @brief Convert a domain and name to SID
613 * @param dom_name Domain name (possibly "")
614 * @param name User or group name
615 * @param *sid Pointer to the resolved domain SID
616 * @param *name_type Pointer to the SID type
620 wbcErr
wbcLookupName(const char *dom_name
,
622 struct wbcDomainSid
*sid
,
623 enum wbcSidType
*name_type
);
626 * @brief Convert a SID to a domain and name
628 * @param *sid Pointer to the domain SID to be resolved
629 * @param domain Resolved Domain name (possibly "")
630 * @param name Resolved User or group name
631 * @param *name_type Pointer to the resolved SID type
635 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
638 enum wbcSidType
*name_type
);
640 struct wbcTranslatedName
{
641 enum wbcSidType type
;
646 wbcErr
wbcLookupSids(const struct wbcDomainSid
*sids
, int num_sids
,
647 struct wbcDomainInfo
**domains
, int *num_domains
,
648 struct wbcTranslatedName
**names
);
651 * @brief Translate a collection of RIDs within a domain to names
653 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
656 const char **domain_name
,
658 enum wbcSidType
**types
);
661 * @brief Get the groups a user belongs to
663 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
664 bool domain_groups_only
,
666 struct wbcDomainSid
**sids
);
669 * @brief Get alias membership for sids
671 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
672 struct wbcDomainSid
*sids
,
674 uint32_t **alias_rids
,
675 uint32_t *num_alias_rids
);
680 wbcErr
wbcListUsers(const char *domain_name
,
682 const char ***users
);
685 * @brief Lists Groups
687 wbcErr
wbcListGroups(const char *domain_name
,
688 uint32_t *num_groups
,
689 const char ***groups
);
691 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
694 enum wbcSidType
*pname_type
);
696 /**********************************************************
697 * SID/uid/gid Mappings
698 **********************************************************/
701 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
703 * @param *sid Pointer to the domain SID to be resolved
704 * @param *puid Pointer to the resolved uid_t value
709 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
713 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
715 * @param *sid Pointer to the domain SID to be resolved
716 * @param *puid Pointer to the resolved uid_t value
721 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
725 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
727 * @param uid Unix uid to be resolved
728 * @param *sid Pointer to the resolved domain SID
733 wbcErr
wbcUidToSid(uid_t uid
,
734 struct wbcDomainSid
*sid
);
737 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
739 * @param uid Unix uid to be resolved
740 * @param *sid Pointer to the resolved domain SID
745 wbcErr
wbcQueryUidToSid(uid_t uid
,
746 struct wbcDomainSid
*sid
);
749 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
751 * @param *sid Pointer to the domain SID to be resolved
752 * @param *pgid Pointer to the resolved gid_t value
757 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
761 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
763 * @param *sid Pointer to the domain SID to be resolved
764 * @param *pgid Pointer to the resolved gid_t value
769 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
773 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
775 * @param gid Unix gid to be resolved
776 * @param *sid Pointer to the resolved domain SID
781 wbcErr
wbcGidToSid(gid_t gid
,
782 struct wbcDomainSid
*sid
);
785 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
787 * @param gid Unix gid to be resolved
788 * @param *sid Pointer to the resolved domain SID
793 wbcErr
wbcQueryGidToSid(gid_t gid
,
794 struct wbcDomainSid
*sid
);
797 WBC_ID_TYPE_NOT_SPECIFIED
,
802 union wbcUnixIdContainer
{
809 union wbcUnixIdContainer id
;
813 * @brief Convert a list of sids to unix ids
815 * @param sids Pointer to an array of SIDs to convert
816 * @param num_sids Number of SIDs
817 * @param ids Preallocated output array for translated IDs
822 wbcErr
wbcSidsToUnixIds(const struct wbcDomainSid
*sids
, uint32_t num_sids
,
823 struct wbcUnixId
*ids
);
826 * @brief Obtain a new uid from Winbind
828 * @param *puid *pointer to the allocated uid
832 wbcErr
wbcAllocateUid(uid_t
*puid
);
835 * @brief Obtain a new gid from Winbind
837 * @param *pgid Pointer to the allocated gid
841 wbcErr
wbcAllocateGid(gid_t
*pgid
);
844 * @brief Set an user id mapping
846 * @param uid Uid of the desired mapping.
847 * @param *sid Pointer to the sid of the diresired mapping.
851 * @deprecated This method is not impemented any more and should
852 * be removed in the next major version change.
854 wbcErr
wbcSetUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
857 * @brief Set a group id mapping
859 * @param gid Gid of the desired mapping.
860 * @param *sid Pointer to the sid of the diresired mapping.
864 * @deprecated This method is not impemented any more and should
865 * be removed in the next major version change.
867 wbcErr
wbcSetGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
870 * @brief Remove a user id mapping
872 * @param uid Uid of the mapping to remove.
873 * @param *sid Pointer to the sid of the mapping to remove.
877 * @deprecated This method is not impemented any more and should
878 * be removed in the next major version change.
880 wbcErr
wbcRemoveUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
883 * @brief Remove a group id mapping
885 * @param gid Gid of the mapping to remove.
886 * @param *sid Pointer to the sid of the mapping to remove.
890 * @deprecated This method is not impemented any more and should
891 * be removed in the next major version change.
893 wbcErr
wbcRemoveGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
896 * @brief Set the highwater mark for allocated uids.
898 * @param uid_hwm The new uid highwater mark value
902 * @deprecated This method is not impemented any more and should
903 * be removed in the next major version change.
905 wbcErr
wbcSetUidHwm(uid_t uid_hwm
);
908 * @brief Set the highwater mark for allocated gids.
910 * @param gid_hwm The new gid highwater mark value
914 * @deprecated This method is not impemented any more and should
915 * be removed in the next major version change.
917 wbcErr
wbcSetGidHwm(gid_t gid_hwm
);
919 /**********************************************************
920 * NSS Lookup User/Group details
921 **********************************************************/
924 * @brief Fill in a struct passwd* for a domain user based
927 * @param *name Username to lookup
928 * @param **pwd Pointer to resulting struct passwd* from the query.
932 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
935 * @brief Fill in a struct passwd* for a domain user based
938 * @param uid Uid to lookup
939 * @param **pwd Pointer to resulting struct passwd* from the query.
943 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
946 * @brief Fill in a struct passwd* for a domain user based
949 * @param sid Sid to lookup
950 * @param **pwd Pointer to resulting struct passwd* from the query.
954 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
957 * @brief Fill in a struct passwd* for a domain user based
960 * @param *name Username to lookup
961 * @param **grp Pointer to resulting struct group* from the query.
965 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
968 * @brief Fill in a struct passwd* for a domain user based
971 * @param gid Uid to lookup
972 * @param **grp Pointer to resulting struct group* from the query.
976 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
979 * @brief Reset the passwd iterator
983 wbcErr
wbcSetpwent(void);
986 * @brief Close the passwd iterator
990 wbcErr
wbcEndpwent(void);
993 * @brief Return the next struct passwd* entry from the pwent iterator
995 * @param **pwd Pointer to resulting struct passwd* from the query.
999 wbcErr
wbcGetpwent(struct passwd
**pwd
);
1002 * @brief Reset the group iterator
1006 wbcErr
wbcSetgrent(void);
1009 * @brief Close the group iterator
1013 wbcErr
wbcEndgrent(void);
1016 * @brief Return the next struct group* entry from the pwent iterator
1018 * @param **grp Pointer to resulting struct group* from the query.
1022 wbcErr
wbcGetgrent(struct group
**grp
);
1025 * @brief Return the next struct group* entry from the pwent iterator
1027 * This is similar to #wbcGetgrent, just that the member list is empty
1029 * @param **grp Pointer to resulting struct group* from the query.
1033 wbcErr
wbcGetgrlist(struct group
**grp
);
1036 * @brief Return the unix group array belonging to the given user
1038 * @param *account The given user name
1039 * @param *num_groups Number of elements returned in the groups array
1040 * @param **_groups Pointer to resulting gid_t array.
1044 wbcErr
wbcGetGroups(const char *account
,
1045 uint32_t *num_groups
,
1049 /**********************************************************
1050 * Lookup Domain information
1051 **********************************************************/
1054 * @brief Lookup the current status of a trusted domain
1056 * @param domain The domain to query
1058 * @param dinfo A pointer to store the returned domain_info struct.
1062 wbcErr
wbcDomainInfo(const char *domain
,
1063 struct wbcDomainInfo
**dinfo
);
1066 * @brief Lookup the currently contacted DCs
1068 * @param domain The domain to query
1070 * @param num_dcs Number of DCs currently known
1071 * @param dc_names Names of the currently known DCs
1072 * @param dc_ips IP addresses of the currently known DCs
1076 wbcErr
wbcDcInfo(const char *domain
, size_t *num_dcs
,
1077 const char ***dc_names
, const char ***dc_ips
);
1080 * @brief Enumerate the domain trusts known by Winbind
1082 * @param **domains Pointer to the allocated domain list array
1083 * @param *num_domains Pointer to number of domains returned
1087 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
1088 size_t *num_domains
);
1090 /* Flags for wbcLookupDomainController */
1092 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1093 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1094 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1095 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1096 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1097 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1098 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1099 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1100 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1101 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1102 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1103 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1104 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1105 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1106 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1107 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1108 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1109 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1110 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1113 * @brief Enumerate the domain trusts known by Winbind
1115 * @param domain Name of the domain to query for a DC
1116 * @param flags Bit flags used to control the domain location query
1117 * @param *dc_info Pointer to the returned domain controller information
1121 wbcErr
wbcLookupDomainController(const char *domain
,
1123 struct wbcDomainControllerInfo
**dc_info
);
1126 * @brief Get extended domain controller information
1128 * @param domain Name of the domain to query for a DC
1129 * @param guid Guid of the domain to query for a DC
1130 * @param site Site of the domain to query for a DC
1131 * @param flags Bit flags used to control the domain location query
1132 * @param *dc_info Pointer to the returned extended domain controller information
1136 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1137 struct wbcGuid
*guid
,
1140 struct wbcDomainControllerInfoEx
**dc_info
);
1142 /**********************************************************
1143 * Athenticate functions
1144 **********************************************************/
1147 * @brief Authenticate a username/password pair
1149 * @param username Name of user to authenticate
1150 * @param password Clear text password os user
1154 wbcErr
wbcAuthenticateUser(const char *username
,
1155 const char *password
);
1158 * @brief Authenticate with more detailed information
1160 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1161 * is not supported yet
1162 * @param info Output details on WBC_ERR_SUCCESS
1163 * @param error Output details on WBC_ERR_AUTH_ERROR
1167 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1168 struct wbcAuthUserInfo
**info
,
1169 struct wbcAuthErrorInfo
**error
);
1172 * @brief Logon a User
1174 * @param[in] params Pointer to a wbcLogonUserParams structure
1175 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1176 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1177 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1181 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1182 struct wbcLogonUserInfo
**info
,
1183 struct wbcAuthErrorInfo
**error
,
1184 struct wbcUserPasswordPolicyInfo
**policy
);
1187 * @brief Trigger a logoff notification to Winbind for a specific user
1189 * @param username Name of user to remove from Winbind's list of
1191 * @param uid Uid assigned to the username
1192 * @param ccfilename Absolute path to the Krb5 credentials cache to
1197 wbcErr
wbcLogoffUser(const char *username
,
1199 const char *ccfilename
);
1202 * @brief Trigger an extended logoff notification to Winbind for a specific user
1204 * @param params A wbcLogoffUserParams structure
1205 * @param error User output details on error
1209 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1210 struct wbcAuthErrorInfo
**error
);
1213 * @brief Change a password for a user
1215 * @param username Name of user to authenticate
1216 * @param old_password Old clear text password of user
1217 * @param new_password New clear text password of user
1221 wbcErr
wbcChangeUserPassword(const char *username
,
1222 const char *old_password
,
1223 const char *new_password
);
1226 * @brief Change a password for a user with more detailed information upon
1229 * @param params Input parameters
1230 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1231 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1232 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1236 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1237 struct wbcAuthErrorInfo
**error
,
1238 enum wbcPasswordChangeRejectReason
*reject_reason
,
1239 struct wbcUserPasswordPolicyInfo
**policy
);
1242 * @brief Authenticate a user with cached credentials
1244 * @param *params Pointer to a wbcCredentialCacheParams structure
1245 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1246 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1250 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1251 struct wbcCredentialCacheInfo
**info
,
1252 struct wbcAuthErrorInfo
**error
);
1255 * @brief Save a password with winbind for doing wbcCredentialCache() later
1257 * @param *user Username
1258 * @param *password Password
1262 wbcErr
wbcCredentialSave(const char *user
, const char *password
);
1264 /**********************************************************
1266 **********************************************************/
1269 * @brief Resolve a NetbiosName via WINS
1271 * @param name Name to resolve
1272 * @param *ip Pointer to the ip address string
1276 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1279 * @brief Resolve an IP address via WINS into a NetbiosName
1281 * @param ip The ip address string
1282 * @param *name Pointer to the name
1287 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1289 /**********************************************************
1290 * Trusted domain functions
1291 **********************************************************/
1294 * @brief Trigger a verification of the trust credentials of a specific domain
1296 * @param *domain The name of the domain.
1297 * @param error Output details on WBC_ERR_AUTH_ERROR
1301 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1302 struct wbcAuthErrorInfo
**error
);
1305 * @brief Trigger a change of the trust credentials for a specific domain
1307 * @param *domain The name of the domain.
1308 * @param error Output details on WBC_ERR_AUTH_ERROR
1312 wbcErr
wbcChangeTrustCredentials(const char *domain
,
1313 struct wbcAuthErrorInfo
**error
);
1316 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1317 * version of wbcCheckTrustCredentials
1319 * @param *domain The name of the domain, only NULL for the default domain is
1320 * supported yet. Other values than NULL will result in
1321 * WBC_ERR_NOT_IMPLEMENTED.
1322 * @param error Output details on WBC_ERR_AUTH_ERROR
1326 wbcErr
wbcPingDc(const char *domain
, struct wbcAuthErrorInfo
**error
);
1328 /**********************************************************
1330 **********************************************************/
1333 * @brief Initialize a named blob and add to list of blobs
1335 * @param[in,out] num_blobs Pointer to the number of blobs
1336 * @param[in,out] blobs Pointer to an array of blobs
1337 * @param[in] name Name of the new named blob
1338 * @param[in] flags Flags of the new named blob
1339 * @param[in] data Blob data of new blob
1340 * @param[in] length Blob data length of new blob
1344 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1345 struct wbcNamedBlob
**blobs
,
1351 #endif /* _WBCLIENT_H */