2 Unix SMB/CIFS implementation.
6 Copyright (C) Gerald (Jerry) Carter 2007
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 3 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 /* Define error types */
31 * @brief Status codes returned from wbc functions
35 WBC_ERR_SUCCESS
= 0, /**< Successful completion **/
36 WBC_ERR_NOT_IMPLEMENTED
,/**< Function not implemented **/
37 WBC_ERR_UNKNOWN_FAILURE
,/**< General failure **/
38 WBC_ERR_NO_MEMORY
, /**< Memory allocation error **/
39 WBC_ERR_INVALID_SID
, /**< Invalid SID format **/
40 WBC_ERR_INVALID_PARAM
, /**< An Invalid parameter was supplied **/
41 WBC_ERR_WINBIND_NOT_AVAILABLE
, /**< Winbind daemon is not available **/
42 WBC_ERR_DOMAIN_NOT_FOUND
, /**< Domain is not trusted or cannot be found **/
43 WBC_ERR_INVALID_RESPONSE
, /**< Winbind returned an invalid response **/
44 WBC_ERR_NSS_ERROR
, /**< NSS_STATUS error **/
45 WBC_ERR_AUTH_ERROR
, /**< Authentication failed **/
46 WBC_ERR_UNKNOWN_USER
, /**< User account cannot be found */
47 WBC_ERR_UNKNOWN_GROUP
, /**< Group account cannot be found */
48 WBC_ERR_PWD_CHANGE_FAILED
/**< Password Change has failed */
51 typedef enum _wbcErrType wbcErr
;
53 #define WBC_ERROR_IS_OK(x) ((x) == WBC_ERR_SUCCESS)
55 const char *wbcErrorString(wbcErr error
);
58 * @brief Some useful details about the wbclient library
60 * 0.1: Initial version
61 * 0.2: Added wbcRemoveUidMapping()
62 * Added wbcRemoveGidMapping()
63 * 0.3: Added wbcGetpwsid()
64 * Added wbcGetSidAliases()
65 * 0.4: Added wbcSidTypeString()
66 * 0.5: Added wbcChangeTrustCredentials()
68 #define WBCLIENT_MAJOR_VERSION 0
69 #define WBCLIENT_MINOR_VERSION 5
70 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
71 struct wbcLibraryDetails
{
72 uint16_t major_version
;
73 uint16_t minor_version
;
74 const char *vendor_version
;
78 * @brief Some useful details about the running winbindd
81 struct wbcInterfaceDetails
{
82 uint32_t interface_version
;
83 const char *winbind_version
;
84 char winbind_separator
;
85 const char *netbios_name
;
86 const char *netbios_domain
;
87 const char *dns_domain
;
91 * Data types used by the Winbind Client API
94 #ifndef WBC_MAXSUBAUTHS
95 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
99 * @brief Windows Security Identifier
103 struct wbcDomainSid
{
107 uint32_t sub_auths
[WBC_MAXSUBAUTHS
];
111 * @brief Security Identifier type
115 WBC_SID_NAME_USE_NONE
=0,
117 WBC_SID_NAME_DOM_GRP
=2,
118 WBC_SID_NAME_DOMAIN
=3,
119 WBC_SID_NAME_ALIAS
=4,
120 WBC_SID_NAME_WKN_GRP
=5,
121 WBC_SID_NAME_DELETED
=6,
122 WBC_SID_NAME_INVALID
=7,
123 WBC_SID_NAME_UNKNOWN
=8,
124 WBC_SID_NAME_COMPUTER
=9
128 * @brief Security Identifier with attributes
131 struct wbcSidWithAttr
{
132 struct wbcDomainSid sid
;
136 /* wbcSidWithAttr->attributes */
138 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
139 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
140 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
141 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
142 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
143 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
144 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
147 * @brief Windows GUID
154 uint16_t time_hi_and_version
;
155 uint8_t clock_seq
[2];
160 * @brief Domain Information
163 struct wbcDomainInfo
{
166 struct wbcDomainSid sid
;
167 uint32_t domain_flags
;
168 uint32_t trust_flags
;
172 /* wbcDomainInfo->domain_flags */
174 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
175 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
176 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
177 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
178 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
180 /* wbcDomainInfo->trust_flags */
182 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
183 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
184 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
186 /* wbcDomainInfo->trust_type */
188 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
189 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
190 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
191 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
195 * @brief Auth User Parameters
198 struct wbcAuthUserParams
{
199 const char *account_name
;
200 const char *domain_name
;
201 const char *workstation_name
;
205 uint32_t parameter_control
;
207 enum wbcAuthUserLevel
{
208 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
209 WBC_AUTH_USER_LEVEL_HASH
= 2,
210 WBC_AUTH_USER_LEVEL_RESPONSE
= 3
213 const char *plaintext
;
219 uint8_t challenge
[8];
229 * @brief Generic Blob
241 struct wbcNamedBlob
{
248 * @brief Logon User Parameters
251 struct wbcLogonUserParams
{
252 const char *username
;
253 const char *password
;
255 struct wbcNamedBlob
*blobs
;
259 * @brief ChangePassword Parameters
262 struct wbcChangePasswordParams
{
263 const char *account_name
;
264 const char *domain_name
;
268 enum wbcChangePasswordLevel
{
269 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
270 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
274 const char *plaintext
;
276 uint32_t old_nt_hash_enc_length
;
277 uint8_t *old_nt_hash_enc_data
;
278 uint32_t old_lm_hash_enc_length
;
279 uint8_t *old_lm_hash_enc_data
;
283 const char *plaintext
;
293 /* wbcAuthUserParams->parameter_control */
295 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
296 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
297 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
298 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
299 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
300 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
302 /* wbcAuthUserParams->flags */
304 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
307 * @brief Auth User Information
309 * Some of the strings are maybe NULL
312 struct wbcAuthUserInfo
{
316 char *user_principal
;
319 char *dns_domain_name
;
322 uint8_t user_session_key
[16];
323 uint8_t lm_session_key
[8];
325 uint16_t logon_count
;
326 uint16_t bad_password_count
;
329 uint64_t logoff_time
;
330 uint64_t kickoff_time
;
331 uint64_t pass_last_set_time
;
332 uint64_t pass_can_change_time
;
333 uint64_t pass_must_change_time
;
338 char *home_directory
;
342 * the 1st one is the account sid
343 * the 2nd one is the primary_group sid
344 * followed by the rest of the groups
347 struct wbcSidWithAttr
*sids
;
351 * @brief Logon User Information
353 * Some of the strings are maybe NULL
356 struct wbcLogonUserInfo
{
357 struct wbcAuthUserInfo
*info
;
359 struct wbcNamedBlob
*blobs
;
362 /* wbcAuthUserInfo->user_flags */
364 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
365 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
366 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
367 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
368 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
369 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
370 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
371 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
372 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
373 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
374 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
376 /* wbcAuthUserInfo->acct_flags */
378 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
379 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
380 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
381 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
382 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
383 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
384 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
385 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
386 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
387 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
388 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
389 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
390 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
391 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
392 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
393 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
394 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
395 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
396 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
398 struct wbcAuthErrorInfo
{
402 char *display_string
;
406 * @brief User Password Policy Information
409 /* wbcUserPasswordPolicyInfo->password_properties */
411 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
412 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
413 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
414 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
415 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
416 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
418 struct wbcUserPasswordPolicyInfo
{
419 uint32_t min_length_password
;
420 uint32_t password_history
;
421 uint32_t password_properties
;
423 uint64_t min_passwordage
;
427 * @brief Change Password Reject Reason
430 enum wbcPasswordChangeRejectReason
{
431 WBC_PWD_CHANGE_NO_ERROR
=0,
432 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
=1,
433 WBC_PWD_CHANGE_PWD_IN_HISTORY
=2,
434 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD
=3,
435 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD
=4,
436 WBC_PWD_CHANGE_NOT_COMPLEX
=5,
437 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT
=6,
438 WBC_PWD_CHANGE_FAILED_BY_FILTER
=7,
439 WBC_PWD_CHANGE_PASSWORD_TOO_LONG
=8
442 /* Note: this defines exist for compatibility reasons with existing code */
443 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
444 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
445 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
446 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
449 * @brief Logoff User Parameters
452 struct wbcLogoffUserParams
{
453 const char *username
;
455 struct wbcNamedBlob
*blobs
;
458 /** @brief Credential cache log-on parameters
462 struct wbcCredentialCacheParams
{
463 const char *account_name
;
464 const char *domain_name
;
465 enum wbcCredentialCacheLevel
{
466 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
469 struct wbcNamedBlob
*blobs
;
473 /** @brief Info returned by credential cache auth
477 struct wbcCredentialCacheInfo
{
479 struct wbcNamedBlob
*blobs
;
483 * DomainControllerInfo struct
485 struct wbcDomainControllerInfo
{
490 * DomainControllerInfoEx struct
492 struct wbcDomainControllerInfoEx
{
494 const char *dc_address
;
495 uint16_t dc_address_type
;
496 struct wbcGuid
*domain_guid
;
497 const char *domain_name
;
498 const char *forest_name
;
500 const char *dc_site_name
;
501 const char *client_site_name
;
504 /**********************************************************
506 **********************************************************/
509 * @brief Free library allocated memory
511 * @param * Pointer to free
515 void wbcFreeMemory(void*);
519 * Utility functions for dealing with SIDs
523 * @brief Get a string representation of the SID type
525 * @param type type of the SID
527 * @return string representation of the SID type
529 const char* wbcSidTypeString(enum wbcSidType type
);
532 * @brief Convert a binary SID to a character string
534 * @param sid Binary Security Identifier
535 * @param **sid_string Resulting character string
539 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
543 * @brief Convert a character string to a binary SID
545 * @param *sid_string Character string in the form of S-...
546 * @param sid Resulting binary SID
550 wbcErr
wbcStringToSid(const char *sid_string
,
551 struct wbcDomainSid
*sid
);
554 * Utility functions for dealing with GUIDs
558 * @brief Convert a binary GUID to a character string
560 * @param guid Binary Guid
561 * @param **guid_string Resulting character string
565 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
569 * @brief Convert a character string to a binary GUID
571 * @param *guid_string Character string
572 * @param guid Resulting binary GUID
576 wbcErr
wbcStringToGuid(const char *guid_string
,
577 struct wbcGuid
*guid
);
580 * @brief Ping winbindd to see if the daemon is running
584 wbcErr
wbcPing(void);
586 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
588 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
590 /**********************************************************
591 * Name/SID conversion
592 **********************************************************/
595 * @brief Convert a domain and name to SID
597 * @param dom_name Domain name (possibly "")
598 * @param name User or group name
599 * @param *sid Pointer to the resolved domain SID
600 * @param *name_type Pointer to the SID type
604 wbcErr
wbcLookupName(const char *dom_name
,
606 struct wbcDomainSid
*sid
,
607 enum wbcSidType
*name_type
);
610 * @brief Convert a SID to a domain and name
612 * @param *sid Pointer to the domain SID to be resolved
613 * @param domain Resolved Domain name (possibly "")
614 * @param name Resolved User or group name
615 * @param *name_type Pointer to the resolved SID type
619 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
622 enum wbcSidType
*name_type
);
625 * @brief Translate a collection of RIDs within a domain to names
627 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
630 const char **domain_name
,
632 enum wbcSidType
**types
);
635 * @brief Get the groups a user belongs to
637 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
638 bool domain_groups_only
,
640 struct wbcDomainSid
**sids
);
643 * @brief Get alias membership for sids
645 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
646 struct wbcDomainSid
*sids
,
648 uint32_t **alias_rids
,
649 uint32_t *num_alias_rids
);
654 wbcErr
wbcListUsers(const char *domain_name
,
656 const char ***users
);
659 * @brief Lists Groups
661 wbcErr
wbcListGroups(const char *domain_name
,
662 uint32_t *num_groups
,
663 const char ***groups
);
665 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
668 enum wbcSidType
*pname_type
);
670 /**********************************************************
671 * SID/uid/gid Mappings
672 **********************************************************/
675 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
677 * @param *sid Pointer to the domain SID to be resolved
678 * @param *puid Pointer to the resolved uid_t value
683 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
687 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
689 * @param *sid Pointer to the domain SID to be resolved
690 * @param *puid Pointer to the resolved uid_t value
695 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
699 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
701 * @param uid Unix uid to be resolved
702 * @param *sid Pointer to the resolved domain SID
707 wbcErr
wbcUidToSid(uid_t uid
,
708 struct wbcDomainSid
*sid
);
711 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
713 * @param uid Unix uid to be resolved
714 * @param *sid Pointer to the resolved domain SID
719 wbcErr
wbcQueryUidToSid(uid_t uid
,
720 struct wbcDomainSid
*sid
);
723 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
725 * @param *sid Pointer to the domain SID to be resolved
726 * @param *pgid Pointer to the resolved gid_t value
731 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
735 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
737 * @param *sid Pointer to the domain SID to be resolved
738 * @param *pgid Pointer to the resolved gid_t value
743 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
747 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
749 * @param gid Unix gid to be resolved
750 * @param *sid Pointer to the resolved domain SID
755 wbcErr
wbcGidToSid(gid_t gid
,
756 struct wbcDomainSid
*sid
);
759 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
761 * @param gid Unix gid to be resolved
762 * @param *sid Pointer to the resolved domain SID
767 wbcErr
wbcQueryGidToSid(gid_t gid
,
768 struct wbcDomainSid
*sid
);
771 * @brief Obtain a new uid from Winbind
773 * @param *puid *pointer to the allocated uid
777 wbcErr
wbcAllocateUid(uid_t
*puid
);
780 * @brief Obtain a new gid from Winbind
782 * @param *pgid Pointer to the allocated gid
786 wbcErr
wbcAllocateGid(gid_t
*pgid
);
789 * @brief Set an user id mapping
791 * @param uid Uid of the desired mapping.
792 * @param *sid Pointer to the sid of the diresired mapping.
796 wbcErr
wbcSetUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
799 * @brief Set a group id mapping
801 * @param gid Gid of the desired mapping.
802 * @param *sid Pointer to the sid of the diresired mapping.
806 wbcErr
wbcSetGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
809 * @brief Remove a user id mapping
811 * @param uid Uid of the mapping to remove.
812 * @param *sid Pointer to the sid of the mapping to remove.
816 wbcErr
wbcRemoveUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
819 * @brief Remove a group id mapping
821 * @param gid Gid of the mapping to remove.
822 * @param *sid Pointer to the sid of the mapping to remove.
826 wbcErr
wbcRemoveGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
829 * @brief Set the highwater mark for allocated uids.
831 * @param uid_hwm The new uid highwater mark value
835 wbcErr
wbcSetUidHwm(uid_t uid_hwm
);
838 * @brief Set the highwater mark for allocated gids.
840 * @param gid_hwm The new gid highwater mark value
844 wbcErr
wbcSetGidHwm(gid_t gid_hwm
);
846 /**********************************************************
847 * NSS Lookup User/Group details
848 **********************************************************/
851 * @brief Fill in a struct passwd* for a domain user based
854 * @param *name Username to lookup
855 * @param **pwd Pointer to resulting struct passwd* from the query.
859 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
862 * @brief Fill in a struct passwd* for a domain user based
865 * @param uid Uid to lookup
866 * @param **pwd Pointer to resulting struct passwd* from the query.
870 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
873 * @brief Fill in a struct passwd* for a domain user based
876 * @param sid Sid to lookup
877 * @param **pwd Pointer to resulting struct passwd* from the query.
881 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
884 * @brief Fill in a struct passwd* for a domain user based
887 * @param *name Username to lookup
888 * @param **grp Pointer to resulting struct group* from the query.
892 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
895 * @brief Fill in a struct passwd* for a domain user based
898 * @param gid Uid to lookup
899 * @param **grp Pointer to resulting struct group* from the query.
903 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
906 * @brief Reset the passwd iterator
910 wbcErr
wbcSetpwent(void);
913 * @brief Close the passwd iterator
917 wbcErr
wbcEndpwent(void);
920 * @brief Return the next struct passwd* entry from the pwent iterator
922 * @param **pwd Pointer to resulting struct passwd* from the query.
926 wbcErr
wbcGetpwent(struct passwd
**pwd
);
929 * @brief Reset the group iterator
933 wbcErr
wbcSetgrent(void);
936 * @brief Close the group iterator
940 wbcErr
wbcEndgrent(void);
943 * @brief Return the next struct group* entry from the pwent iterator
945 * @param **grp Pointer to resulting struct group* from the query.
949 wbcErr
wbcGetgrent(struct group
**grp
);
952 * @brief Return the next struct group* entry from the pwent iterator
954 * This is similar to #wbcGetgrent, just that the member list is empty
956 * @param **grp Pointer to resulting struct group* from the query.
960 wbcErr
wbcGetgrlist(struct group
**grp
);
963 * @brief Return the unix group array belonging to the given user
965 * @param *account The given user name
966 * @param *num_groups Number of elements returned in the groups array
967 * @param **_groups Pointer to resulting gid_t array.
971 wbcErr
wbcGetGroups(const char *account
,
972 uint32_t *num_groups
,
976 /**********************************************************
977 * Lookup Domain information
978 **********************************************************/
981 * @brief Lookup the current status of a trusted domain
983 * @param domain Domain to query
984 * @param *info Pointer to returned domain_info struct
988 wbcErr
wbcDomainInfo(const char *domain
,
989 struct wbcDomainInfo
**info
);
992 * @brief Enumerate the domain trusts known by Winbind
994 * @param **domains Pointer to the allocated domain list array
995 * @param *num_domains Pointer to number of domains returned
999 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
1000 size_t *num_domains
);
1002 /* Flags for wbcLookupDomainController */
1004 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1005 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1006 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1007 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1008 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1009 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1010 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1011 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1012 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1013 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1014 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1015 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1016 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1017 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1018 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1019 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1020 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1021 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1022 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1025 * @brief Enumerate the domain trusts known by Winbind
1027 * @param domain Name of the domain to query for a DC
1028 * @param flags Bit flags used to control the domain location query
1029 * @param *dc_info Pointer to the returned domain controller information
1033 wbcErr
wbcLookupDomainController(const char *domain
,
1035 struct wbcDomainControllerInfo
**dc_info
);
1038 * @brief Get extended domain controller information
1040 * @param domain Name of the domain to query for a DC
1041 * @param guid Guid of the domain to query for a DC
1042 * @param site Site of the domain to query for a DC
1043 * @param flags Bit flags used to control the domain location query
1044 * @param *dc_info Pointer to the returned extended domain controller information
1048 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1049 struct wbcGuid
*guid
,
1052 struct wbcDomainControllerInfoEx
**dc_info
);
1054 /**********************************************************
1055 * Athenticate functions
1056 **********************************************************/
1059 * @brief Authenticate a username/password pair
1061 * @param username Name of user to authenticate
1062 * @param password Clear text password os user
1066 wbcErr
wbcAuthenticateUser(const char *username
,
1067 const char *password
);
1070 * @brief Authenticate with more detailed information
1072 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1073 * is not supported yet
1074 * @param info Output details on WBC_ERR_SUCCESS
1075 * @param error Output details on WBC_ERR_AUTH_ERROR
1079 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1080 struct wbcAuthUserInfo
**info
,
1081 struct wbcAuthErrorInfo
**error
);
1084 * @brief Logon a User
1086 * @param[in] params Pointer to a wbcLogonUserParams structure
1087 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1088 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1089 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1093 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1094 struct wbcLogonUserInfo
**info
,
1095 struct wbcAuthErrorInfo
**error
,
1096 struct wbcUserPasswordPolicyInfo
**policy
);
1099 * @brief Trigger a logoff notification to Winbind for a specific user
1101 * @param username Name of user to remove from Winbind's list of
1103 * @param uid Uid assigned to the username
1104 * @param ccfilename Absolute path to the Krb5 credentials cache to
1109 wbcErr
wbcLogoffUser(const char *username
,
1111 const char *ccfilename
);
1114 * @brief Trigger an extended logoff notification to Winbind for a specific user
1116 * @param params A wbcLogoffUserParams structure
1117 * @param error User output details on error
1121 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1122 struct wbcAuthErrorInfo
**error
);
1125 * @brief Change a password for a user
1127 * @param username Name of user to authenticate
1128 * @param old_password Old clear text password of user
1129 * @param new_password New clear text password of user
1133 wbcErr
wbcChangeUserPassword(const char *username
,
1134 const char *old_password
,
1135 const char *new_password
);
1138 * @brief Change a password for a user with more detailed information upon
1141 * @param params Input parameters
1142 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1143 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1144 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1148 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1149 struct wbcAuthErrorInfo
**error
,
1150 enum wbcPasswordChangeRejectReason
*reject_reason
,
1151 struct wbcUserPasswordPolicyInfo
**policy
);
1154 * @brief Authenticate a user with cached credentials
1156 * @param *params Pointer to a wbcCredentialCacheParams structure
1157 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1158 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1162 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1163 struct wbcCredentialCacheInfo
**info
,
1164 struct wbcAuthErrorInfo
**error
);
1166 /**********************************************************
1168 **********************************************************/
1171 * @brief Resolve a NetbiosName via WINS
1173 * @param name Name to resolve
1174 * @param *ip Pointer to the ip address string
1178 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1181 * @brief Resolve an IP address via WINS into a NetbiosName
1183 * @param ip The ip address string
1184 * @param *name Pointer to the name
1189 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1191 /**********************************************************
1192 * Trusted domain functions
1193 **********************************************************/
1196 * @brief Trigger a verification of the trust credentials of a specific domain
1198 * @param *domain The name of the domain.
1199 * @param error Output details on WBC_ERR_AUTH_ERROR
1203 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1204 struct wbcAuthErrorInfo
**error
);
1207 * @brief Trigger a change of the trust credentials for a specific domain
1209 * @param *domain The name of the domain.
1210 * @param error Output details on WBC_ERR_AUTH_ERROR
1214 wbcErr
wbcChangeTrustCredentials(const char *domain
,
1215 struct wbcAuthErrorInfo
**error
);
1217 /**********************************************************
1219 **********************************************************/
1222 * @brief Initialize a named blob and add to list of blobs
1224 * @param[in,out] num_blobs Pointer to the number of blobs
1225 * @param[in,out] blobs Pointer to an array of blobs
1226 * @param[in] name Name of the new named blob
1227 * @param[in] flags Flags of the new named blob
1228 * @param[in] data Blob data of new blob
1229 * @param[in] length Blob data length of new blob
1233 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1234 struct wbcNamedBlob
**blobs
,
1240 #endif /* _WBCLIENT_H */