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()
71 #define WBCLIENT_MAJOR_VERSION 0
72 #define WBCLIENT_MINOR_VERSION 7
73 #define WBCLIENT_VENDOR_VERSION "Samba libwbclient"
74 struct wbcLibraryDetails
{
75 uint16_t major_version
;
76 uint16_t minor_version
;
77 const char *vendor_version
;
81 * @brief Some useful details about the running winbindd
84 struct wbcInterfaceDetails
{
85 uint32_t interface_version
;
86 char *winbind_version
;
87 char winbind_separator
;
94 * Data types used by the Winbind Client API
97 #ifndef WBC_MAXSUBAUTHS
98 #define WBC_MAXSUBAUTHS 15 /* max sub authorities in a SID */
102 * @brief Windows Security Identifier
106 struct wbcDomainSid
{
110 uint32_t sub_auths
[WBC_MAXSUBAUTHS
];
114 * @brief Security Identifier type
118 WBC_SID_NAME_USE_NONE
=0,
120 WBC_SID_NAME_DOM_GRP
=2,
121 WBC_SID_NAME_DOMAIN
=3,
122 WBC_SID_NAME_ALIAS
=4,
123 WBC_SID_NAME_WKN_GRP
=5,
124 WBC_SID_NAME_DELETED
=6,
125 WBC_SID_NAME_INVALID
=7,
126 WBC_SID_NAME_UNKNOWN
=8,
127 WBC_SID_NAME_COMPUTER
=9
131 * @brief Security Identifier with attributes
134 struct wbcSidWithAttr
{
135 struct wbcDomainSid sid
;
139 /* wbcSidWithAttr->attributes */
141 #define WBC_SID_ATTR_GROUP_MANDATORY 0x00000001
142 #define WBC_SID_ATTR_GROUP_ENABLED_BY_DEFAULT 0x00000002
143 #define WBC_SID_ATTR_GROUP_ENABLED 0x00000004
144 #define WBC_SID_ATTR_GROUP_OWNER 0x00000008
145 #define WBC_SID_ATTR_GROUP_USEFOR_DENY_ONLY 0x00000010
146 #define WBC_SID_ATTR_GROUP_RESOURCE 0x20000000
147 #define WBC_SID_ATTR_GROUP_LOGON_ID 0xC0000000
150 * @brief Windows GUID
157 uint16_t time_hi_and_version
;
158 uint8_t clock_seq
[2];
163 * @brief Domain Information
166 struct wbcDomainInfo
{
169 struct wbcDomainSid sid
;
170 uint32_t domain_flags
;
171 uint32_t trust_flags
;
175 /* wbcDomainInfo->domain_flags */
177 #define WBC_DOMINFO_DOMAIN_UNKNOWN 0x00000000
178 #define WBC_DOMINFO_DOMAIN_NATIVE 0x00000001
179 #define WBC_DOMINFO_DOMAIN_AD 0x00000002
180 #define WBC_DOMINFO_DOMAIN_PRIMARY 0x00000004
181 #define WBC_DOMINFO_DOMAIN_OFFLINE 0x00000008
183 /* wbcDomainInfo->trust_flags */
185 #define WBC_DOMINFO_TRUST_TRANSITIVE 0x00000001
186 #define WBC_DOMINFO_TRUST_INCOMING 0x00000002
187 #define WBC_DOMINFO_TRUST_OUTGOING 0x00000004
189 /* wbcDomainInfo->trust_type */
191 #define WBC_DOMINFO_TRUSTTYPE_NONE 0x00000000
192 #define WBC_DOMINFO_TRUSTTYPE_FOREST 0x00000001
193 #define WBC_DOMINFO_TRUSTTYPE_IN_FOREST 0x00000002
194 #define WBC_DOMINFO_TRUSTTYPE_EXTERNAL 0x00000003
197 * @brief Auth User Parameters
200 struct wbcAuthUserParams
{
201 const char *account_name
;
202 const char *domain_name
;
203 const char *workstation_name
;
207 uint32_t parameter_control
;
209 enum wbcAuthUserLevel
{
210 WBC_AUTH_USER_LEVEL_PLAIN
= 1,
211 WBC_AUTH_USER_LEVEL_HASH
= 2,
212 WBC_AUTH_USER_LEVEL_RESPONSE
= 3
215 const char *plaintext
;
221 uint8_t challenge
[8];
231 * @brief Generic Blob
243 struct wbcNamedBlob
{
250 * @brief Logon User Parameters
253 struct wbcLogonUserParams
{
254 const char *username
;
255 const char *password
;
257 struct wbcNamedBlob
*blobs
;
261 * @brief ChangePassword Parameters
264 struct wbcChangePasswordParams
{
265 const char *account_name
;
266 const char *domain_name
;
270 enum wbcChangePasswordLevel
{
271 WBC_CHANGE_PASSWORD_LEVEL_PLAIN
= 1,
272 WBC_CHANGE_PASSWORD_LEVEL_RESPONSE
= 2
276 const char *plaintext
;
278 uint32_t old_nt_hash_enc_length
;
279 uint8_t *old_nt_hash_enc_data
;
280 uint32_t old_lm_hash_enc_length
;
281 uint8_t *old_lm_hash_enc_data
;
285 const char *plaintext
;
295 /* wbcAuthUserParams->parameter_control */
297 #define WBC_MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
298 #define WBC_MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
299 #define WBC_MSV1_0_RETURN_USER_PARAMETERS 0x00000008
300 #define WBC_MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
301 #define WBC_MSV1_0_RETURN_PROFILE_PATH 0x00000200
302 #define WBC_MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
304 /* wbcAuthUserParams->flags */
306 #define WBC_AUTH_PARAM_FLAGS_INTERACTIVE_LOGON 0x00000001
309 * @brief Auth User Information
311 * Some of the strings are maybe NULL
314 struct wbcAuthUserInfo
{
318 char *user_principal
;
321 char *dns_domain_name
;
324 uint8_t user_session_key
[16];
325 uint8_t lm_session_key
[8];
327 uint16_t logon_count
;
328 uint16_t bad_password_count
;
331 uint64_t logoff_time
;
332 uint64_t kickoff_time
;
333 uint64_t pass_last_set_time
;
334 uint64_t pass_can_change_time
;
335 uint64_t pass_must_change_time
;
340 char *home_directory
;
344 * the 1st one is the account sid
345 * the 2nd one is the primary_group sid
346 * followed by the rest of the groups
349 struct wbcSidWithAttr
*sids
;
353 * @brief Logon User Information
355 * Some of the strings are maybe NULL
358 struct wbcLogonUserInfo
{
359 struct wbcAuthUserInfo
*info
;
361 struct wbcNamedBlob
*blobs
;
364 /* wbcAuthUserInfo->user_flags */
366 #define WBC_AUTH_USER_INFO_GUEST 0x00000001
367 #define WBC_AUTH_USER_INFO_NOENCRYPTION 0x00000002
368 #define WBC_AUTH_USER_INFO_CACHED_ACCOUNT 0x00000004
369 #define WBC_AUTH_USER_INFO_USED_LM_PASSWORD 0x00000008
370 #define WBC_AUTH_USER_INFO_EXTRA_SIDS 0x00000020
371 #define WBC_AUTH_USER_INFO_SUBAUTH_SESSION_KEY 0x00000040
372 #define WBC_AUTH_USER_INFO_SERVER_TRUST_ACCOUNT 0x00000080
373 #define WBC_AUTH_USER_INFO_NTLMV2_ENABLED 0x00000100
374 #define WBC_AUTH_USER_INFO_RESOURCE_GROUPS 0x00000200
375 #define WBC_AUTH_USER_INFO_PROFILE_PATH_RETURNED 0x00000400
376 #define WBC_AUTH_USER_INFO_GRACE_LOGON 0x01000000
378 /* wbcAuthUserInfo->acct_flags */
380 #define WBC_ACB_DISABLED 0x00000001 /* 1 User account disabled */
381 #define WBC_ACB_HOMDIRREQ 0x00000002 /* 1 Home directory required */
382 #define WBC_ACB_PWNOTREQ 0x00000004 /* 1 User password not required */
383 #define WBC_ACB_TEMPDUP 0x00000008 /* 1 Temporary duplicate account */
384 #define WBC_ACB_NORMAL 0x00000010 /* 1 Normal user account */
385 #define WBC_ACB_MNS 0x00000020 /* 1 MNS logon user account */
386 #define WBC_ACB_DOMTRUST 0x00000040 /* 1 Interdomain trust account */
387 #define WBC_ACB_WSTRUST 0x00000080 /* 1 Workstation trust account */
388 #define WBC_ACB_SVRTRUST 0x00000100 /* 1 Server trust account */
389 #define WBC_ACB_PWNOEXP 0x00000200 /* 1 User password does not expire */
390 #define WBC_ACB_AUTOLOCK 0x00000400 /* 1 Account auto locked */
391 #define WBC_ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 Encryped text password is allowed */
392 #define WBC_ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 Smart Card required */
393 #define WBC_ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 Trusted for Delegation */
394 #define WBC_ACB_NOT_DELEGATED 0x00004000 /* 1 Not delegated */
395 #define WBC_ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 Use DES key only */
396 #define WBC_ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 Preauth not required */
397 #define WBC_ACB_PW_EXPIRED 0x00020000 /* 1 Password Expired */
398 #define WBC_ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
400 struct wbcAuthErrorInfo
{
404 char *display_string
;
408 * @brief User Password Policy Information
411 /* wbcUserPasswordPolicyInfo->password_properties */
413 #define WBC_DOMAIN_PASSWORD_COMPLEX 0x00000001
414 #define WBC_DOMAIN_PASSWORD_NO_ANON_CHANGE 0x00000002
415 #define WBC_DOMAIN_PASSWORD_NO_CLEAR_CHANGE 0x00000004
416 #define WBC_DOMAIN_PASSWORD_LOCKOUT_ADMINS 0x00000008
417 #define WBC_DOMAIN_PASSWORD_STORE_CLEARTEXT 0x00000010
418 #define WBC_DOMAIN_REFUSE_PASSWORD_CHANGE 0x00000020
420 struct wbcUserPasswordPolicyInfo
{
421 uint32_t min_length_password
;
422 uint32_t password_history
;
423 uint32_t password_properties
;
425 uint64_t min_passwordage
;
429 * @brief Change Password Reject Reason
432 enum wbcPasswordChangeRejectReason
{
433 WBC_PWD_CHANGE_NO_ERROR
=0,
434 WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
=1,
435 WBC_PWD_CHANGE_PWD_IN_HISTORY
=2,
436 WBC_PWD_CHANGE_USERNAME_IN_PASSWORD
=3,
437 WBC_PWD_CHANGE_FULLNAME_IN_PASSWORD
=4,
438 WBC_PWD_CHANGE_NOT_COMPLEX
=5,
439 WBC_PWD_CHANGE_MACHINE_NOT_DEFAULT
=6,
440 WBC_PWD_CHANGE_FAILED_BY_FILTER
=7,
441 WBC_PWD_CHANGE_PASSWORD_TOO_LONG
=8
444 /* Note: this defines exist for compatibility reasons with existing code */
445 #define WBC_PWD_CHANGE_REJECT_OTHER WBC_PWD_CHANGE_NO_ERROR
446 #define WBC_PWD_CHANGE_REJECT_TOO_SHORT WBC_PWD_CHANGE_PASSWORD_TOO_SHORT
447 #define WBC_PWD_CHANGE_REJECT_IN_HISTORY WBC_PWD_CHANGE_PWD_IN_HISTORY
448 #define WBC_PWD_CHANGE_REJECT_COMPLEXITY WBC_PWD_CHANGE_NOT_COMPLEX
451 * @brief Logoff User Parameters
454 struct wbcLogoffUserParams
{
455 const char *username
;
457 struct wbcNamedBlob
*blobs
;
460 /** @brief Credential cache log-on parameters
464 struct wbcCredentialCacheParams
{
465 const char *account_name
;
466 const char *domain_name
;
467 enum wbcCredentialCacheLevel
{
468 WBC_CREDENTIAL_CACHE_LEVEL_NTLMSSP
= 1
471 struct wbcNamedBlob
*blobs
;
475 /** @brief Info returned by credential cache auth
479 struct wbcCredentialCacheInfo
{
481 struct wbcNamedBlob
*blobs
;
485 * DomainControllerInfo struct
487 struct wbcDomainControllerInfo
{
492 * DomainControllerInfoEx struct
494 struct wbcDomainControllerInfoEx
{
496 const char *dc_address
;
497 uint16_t dc_address_type
;
498 struct wbcGuid
*domain_guid
;
499 const char *domain_name
;
500 const char *forest_name
;
502 const char *dc_site_name
;
503 const char *client_site_name
;
506 /**********************************************************
508 **********************************************************/
511 * @brief Free library allocated memory
513 * @param * Pointer to free
517 void wbcFreeMemory(void*);
521 * Utility functions for dealing with SIDs
525 * @brief Get a string representation of the SID type
527 * @param type type of the SID
529 * @return string representation of the SID type
531 const char* wbcSidTypeString(enum wbcSidType type
);
533 #define WBC_SID_STRING_BUFLEN (15*11+25)
536 * @brief Print a sid into a buffer
538 * @param sid Binary Security Identifier
539 * @param buf Target buffer
540 * @param buflen Target buffer length
542 * @return Resulting string length.
544 int wbcSidToStringBuf(const struct wbcDomainSid
*sid
, char *buf
, int buflen
);
547 * @brief Convert a binary SID to a character string
549 * @param sid Binary Security Identifier
550 * @param **sid_string Resulting character string
554 wbcErr
wbcSidToString(const struct wbcDomainSid
*sid
,
558 * @brief Convert a character string to a binary SID
560 * @param *sid_string Character string in the form of S-...
561 * @param sid Resulting binary SID
565 wbcErr
wbcStringToSid(const char *sid_string
,
566 struct wbcDomainSid
*sid
);
569 * Utility functions for dealing with GUIDs
573 * @brief Convert a binary GUID to a character string
575 * @param guid Binary Guid
576 * @param **guid_string Resulting character string
580 wbcErr
wbcGuidToString(const struct wbcGuid
*guid
,
584 * @brief Convert a character string to a binary GUID
586 * @param *guid_string Character string
587 * @param guid Resulting binary GUID
591 wbcErr
wbcStringToGuid(const char *guid_string
,
592 struct wbcGuid
*guid
);
595 * @brief Ping winbindd to see if the daemon is running
599 wbcErr
wbcPing(void);
601 wbcErr
wbcLibraryDetails(struct wbcLibraryDetails
**details
);
603 wbcErr
wbcInterfaceDetails(struct wbcInterfaceDetails
**details
);
605 /**********************************************************
606 * Name/SID conversion
607 **********************************************************/
610 * @brief Convert a domain and name to SID
612 * @param dom_name Domain name (possibly "")
613 * @param name User or group name
614 * @param *sid Pointer to the resolved domain SID
615 * @param *name_type Pointer to the SID type
619 wbcErr
wbcLookupName(const char *dom_name
,
621 struct wbcDomainSid
*sid
,
622 enum wbcSidType
*name_type
);
625 * @brief Convert a SID to a domain and name
627 * @param *sid Pointer to the domain SID to be resolved
628 * @param domain Resolved Domain name (possibly "")
629 * @param name Resolved User or group name
630 * @param *name_type Pointer to the resolved SID type
634 wbcErr
wbcLookupSid(const struct wbcDomainSid
*sid
,
637 enum wbcSidType
*name_type
);
640 * @brief Translate a collection of RIDs within a domain to names
642 wbcErr
wbcLookupRids(struct wbcDomainSid
*dom_sid
,
645 const char **domain_name
,
647 enum wbcSidType
**types
);
650 * @brief Get the groups a user belongs to
652 wbcErr
wbcLookupUserSids(const struct wbcDomainSid
*user_sid
,
653 bool domain_groups_only
,
655 struct wbcDomainSid
**sids
);
658 * @brief Get alias membership for sids
660 wbcErr
wbcGetSidAliases(const struct wbcDomainSid
*dom_sid
,
661 struct wbcDomainSid
*sids
,
663 uint32_t **alias_rids
,
664 uint32_t *num_alias_rids
);
669 wbcErr
wbcListUsers(const char *domain_name
,
671 const char ***users
);
674 * @brief Lists Groups
676 wbcErr
wbcListGroups(const char *domain_name
,
677 uint32_t *num_groups
,
678 const char ***groups
);
680 wbcErr
wbcGetDisplayName(const struct wbcDomainSid
*sid
,
683 enum wbcSidType
*pname_type
);
685 /**********************************************************
686 * SID/uid/gid Mappings
687 **********************************************************/
690 * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed
692 * @param *sid Pointer to the domain SID to be resolved
693 * @param *puid Pointer to the resolved uid_t value
698 wbcErr
wbcSidToUid(const struct wbcDomainSid
*sid
,
702 * @brief Convert a Windows SID to a Unix uid if there already is a mapping
704 * @param *sid Pointer to the domain SID to be resolved
705 * @param *puid Pointer to the resolved uid_t value
710 wbcErr
wbcQuerySidToUid(const struct wbcDomainSid
*sid
,
714 * @brief Convert a Unix uid to a Windows SID, allocating a SID if needed
716 * @param uid Unix uid to be resolved
717 * @param *sid Pointer to the resolved domain SID
722 wbcErr
wbcUidToSid(uid_t uid
,
723 struct wbcDomainSid
*sid
);
726 * @brief Convert a Unix uid to a Windows SID if there already is a mapping
728 * @param uid Unix uid to be resolved
729 * @param *sid Pointer to the resolved domain SID
734 wbcErr
wbcQueryUidToSid(uid_t uid
,
735 struct wbcDomainSid
*sid
);
738 * @brief Convert a Windows SID to a Unix gid, allocating a gid if needed
740 * @param *sid Pointer to the domain SID to be resolved
741 * @param *pgid Pointer to the resolved gid_t value
746 wbcErr
wbcSidToGid(const struct wbcDomainSid
*sid
,
750 * @brief Convert a Windows SID to a Unix gid if there already is a mapping
752 * @param *sid Pointer to the domain SID to be resolved
753 * @param *pgid Pointer to the resolved gid_t value
758 wbcErr
wbcQuerySidToGid(const struct wbcDomainSid
*sid
,
762 * @brief Convert a Unix gid to a Windows SID, allocating a SID if needed
764 * @param gid Unix gid to be resolved
765 * @param *sid Pointer to the resolved domain SID
770 wbcErr
wbcGidToSid(gid_t gid
,
771 struct wbcDomainSid
*sid
);
774 * @brief Convert a Unix gid to a Windows SID if there already is a mapping
776 * @param gid Unix gid to be resolved
777 * @param *sid Pointer to the resolved domain SID
782 wbcErr
wbcQueryGidToSid(gid_t gid
,
783 struct wbcDomainSid
*sid
);
786 * @brief Obtain a new uid from Winbind
788 * @param *puid *pointer to the allocated uid
792 wbcErr
wbcAllocateUid(uid_t
*puid
);
795 * @brief Obtain a new gid from Winbind
797 * @param *pgid Pointer to the allocated gid
801 wbcErr
wbcAllocateGid(gid_t
*pgid
);
804 * @brief Set an user id mapping
806 * @param uid Uid of the desired mapping.
807 * @param *sid Pointer to the sid of the diresired mapping.
811 * @deprecated This method is not impemented any more and should
812 * be removed in the next major version change.
814 wbcErr
wbcSetUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
817 * @brief Set a group id mapping
819 * @param gid Gid of the desired mapping.
820 * @param *sid Pointer to the sid of the diresired mapping.
824 * @deprecated This method is not impemented any more and should
825 * be removed in the next major version change.
827 wbcErr
wbcSetGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
830 * @brief Remove a user id mapping
832 * @param uid Uid of the mapping to remove.
833 * @param *sid Pointer to the sid of the mapping to remove.
837 * @deprecated This method is not impemented any more and should
838 * be removed in the next major version change.
840 wbcErr
wbcRemoveUidMapping(uid_t uid
, const struct wbcDomainSid
*sid
);
843 * @brief Remove a group id mapping
845 * @param gid Gid of the mapping to remove.
846 * @param *sid Pointer to the sid of the mapping to remove.
850 * @deprecated This method is not impemented any more and should
851 * be removed in the next major version change.
853 wbcErr
wbcRemoveGidMapping(gid_t gid
, const struct wbcDomainSid
*sid
);
856 * @brief Set the highwater mark for allocated uids.
858 * @param uid_hwm The new uid highwater mark value
862 * @deprecated This method is not impemented any more and should
863 * be removed in the next major version change.
865 wbcErr
wbcSetUidHwm(uid_t uid_hwm
);
868 * @brief Set the highwater mark for allocated gids.
870 * @param gid_hwm The new gid highwater mark value
874 * @deprecated This method is not impemented any more and should
875 * be removed in the next major version change.
877 wbcErr
wbcSetGidHwm(gid_t gid_hwm
);
879 /**********************************************************
880 * NSS Lookup User/Group details
881 **********************************************************/
884 * @brief Fill in a struct passwd* for a domain user based
887 * @param *name Username to lookup
888 * @param **pwd Pointer to resulting struct passwd* from the query.
892 wbcErr
wbcGetpwnam(const char *name
, struct passwd
**pwd
);
895 * @brief Fill in a struct passwd* for a domain user based
898 * @param uid Uid to lookup
899 * @param **pwd Pointer to resulting struct passwd* from the query.
903 wbcErr
wbcGetpwuid(uid_t uid
, struct passwd
**pwd
);
906 * @brief Fill in a struct passwd* for a domain user based
909 * @param sid Sid to lookup
910 * @param **pwd Pointer to resulting struct passwd* from the query.
914 wbcErr
wbcGetpwsid(struct wbcDomainSid
* sid
, struct passwd
**pwd
);
917 * @brief Fill in a struct passwd* for a domain user based
920 * @param *name Username to lookup
921 * @param **grp Pointer to resulting struct group* from the query.
925 wbcErr
wbcGetgrnam(const char *name
, struct group
**grp
);
928 * @brief Fill in a struct passwd* for a domain user based
931 * @param gid Uid to lookup
932 * @param **grp Pointer to resulting struct group* from the query.
936 wbcErr
wbcGetgrgid(gid_t gid
, struct group
**grp
);
939 * @brief Reset the passwd iterator
943 wbcErr
wbcSetpwent(void);
946 * @brief Close the passwd iterator
950 wbcErr
wbcEndpwent(void);
953 * @brief Return the next struct passwd* entry from the pwent iterator
955 * @param **pwd Pointer to resulting struct passwd* from the query.
959 wbcErr
wbcGetpwent(struct passwd
**pwd
);
962 * @brief Reset the group iterator
966 wbcErr
wbcSetgrent(void);
969 * @brief Close the group iterator
973 wbcErr
wbcEndgrent(void);
976 * @brief Return the next struct group* entry from the pwent iterator
978 * @param **grp Pointer to resulting struct group* from the query.
982 wbcErr
wbcGetgrent(struct group
**grp
);
985 * @brief Return the next struct group* entry from the pwent iterator
987 * This is similar to #wbcGetgrent, just that the member list is empty
989 * @param **grp Pointer to resulting struct group* from the query.
993 wbcErr
wbcGetgrlist(struct group
**grp
);
996 * @brief Return the unix group array belonging to the given user
998 * @param *account The given user name
999 * @param *num_groups Number of elements returned in the groups array
1000 * @param **_groups Pointer to resulting gid_t array.
1004 wbcErr
wbcGetGroups(const char *account
,
1005 uint32_t *num_groups
,
1009 /**********************************************************
1010 * Lookup Domain information
1011 **********************************************************/
1014 * @brief Lookup the current status of a trusted domain
1016 * @param domain The domain to query
1018 * @param dinfo A pointer to store the returned domain_info struct.
1022 wbcErr
wbcDomainInfo(const char *domain
,
1023 struct wbcDomainInfo
**dinfo
);
1026 * @brief Lookup the currently contacted DCs
1028 * @param domain The domain to query
1030 * @param num_dcs Number of DCs currently known
1031 * @param dc_names Names of the currently known DCs
1032 * @param dc_ips IP addresses of the currently known DCs
1036 wbcErr
wbcDcInfo(const char *domain
, size_t *num_dcs
,
1037 const char ***dc_names
, const char ***dc_ips
);
1040 * @brief Enumerate the domain trusts known by Winbind
1042 * @param **domains Pointer to the allocated domain list array
1043 * @param *num_domains Pointer to number of domains returned
1047 wbcErr
wbcListTrusts(struct wbcDomainInfo
**domains
,
1048 size_t *num_domains
);
1050 /* Flags for wbcLookupDomainController */
1052 #define WBC_LOOKUP_DC_FORCE_REDISCOVERY 0x00000001
1053 #define WBC_LOOKUP_DC_DS_REQUIRED 0x00000010
1054 #define WBC_LOOKUP_DC_DS_PREFERRED 0x00000020
1055 #define WBC_LOOKUP_DC_GC_SERVER_REQUIRED 0x00000040
1056 #define WBC_LOOKUP_DC_PDC_REQUIRED 0x00000080
1057 #define WBC_LOOKUP_DC_BACKGROUND_ONLY 0x00000100
1058 #define WBC_LOOKUP_DC_IP_REQUIRED 0x00000200
1059 #define WBC_LOOKUP_DC_KDC_REQUIRED 0x00000400
1060 #define WBC_LOOKUP_DC_TIMESERV_REQUIRED 0x00000800
1061 #define WBC_LOOKUP_DC_WRITABLE_REQUIRED 0x00001000
1062 #define WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED 0x00002000
1063 #define WBC_LOOKUP_DC_AVOID_SELF 0x00004000
1064 #define WBC_LOOKUP_DC_ONLY_LDAP_NEEDED 0x00008000
1065 #define WBC_LOOKUP_DC_IS_FLAT_NAME 0x00010000
1066 #define WBC_LOOKUP_DC_IS_DNS_NAME 0x00020000
1067 #define WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE 0x00040000
1068 #define WBC_LOOKUP_DC_DS_6_REQUIRED 0x00080000
1069 #define WBC_LOOKUP_DC_RETURN_DNS_NAME 0x40000000
1070 #define WBC_LOOKUP_DC_RETURN_FLAT_NAME 0x80000000
1073 * @brief Enumerate the domain trusts known by Winbind
1075 * @param domain Name of the domain to query for a DC
1076 * @param flags Bit flags used to control the domain location query
1077 * @param *dc_info Pointer to the returned domain controller information
1081 wbcErr
wbcLookupDomainController(const char *domain
,
1083 struct wbcDomainControllerInfo
**dc_info
);
1086 * @brief Get extended domain controller information
1088 * @param domain Name of the domain to query for a DC
1089 * @param guid Guid of the domain to query for a DC
1090 * @param site Site of the domain to query for a DC
1091 * @param flags Bit flags used to control the domain location query
1092 * @param *dc_info Pointer to the returned extended domain controller information
1096 wbcErr
wbcLookupDomainControllerEx(const char *domain
,
1097 struct wbcGuid
*guid
,
1100 struct wbcDomainControllerInfoEx
**dc_info
);
1102 /**********************************************************
1103 * Athenticate functions
1104 **********************************************************/
1107 * @brief Authenticate a username/password pair
1109 * @param username Name of user to authenticate
1110 * @param password Clear text password os user
1114 wbcErr
wbcAuthenticateUser(const char *username
,
1115 const char *password
);
1118 * @brief Authenticate with more detailed information
1120 * @param params Input parameters, WBC_AUTH_USER_LEVEL_HASH
1121 * is not supported yet
1122 * @param info Output details on WBC_ERR_SUCCESS
1123 * @param error Output details on WBC_ERR_AUTH_ERROR
1127 wbcErr
wbcAuthenticateUserEx(const struct wbcAuthUserParams
*params
,
1128 struct wbcAuthUserInfo
**info
,
1129 struct wbcAuthErrorInfo
**error
);
1132 * @brief Logon a User
1134 * @param[in] params Pointer to a wbcLogonUserParams structure
1135 * @param[out] info Pointer to a pointer to a wbcLogonUserInfo structure
1136 * @param[out] error Pointer to a pointer to a wbcAuthErrorInfo structure
1137 * @param[out] policy Pointer to a pointer to a wbcUserPasswordPolicyInfo structure
1141 wbcErr
wbcLogonUser(const struct wbcLogonUserParams
*params
,
1142 struct wbcLogonUserInfo
**info
,
1143 struct wbcAuthErrorInfo
**error
,
1144 struct wbcUserPasswordPolicyInfo
**policy
);
1147 * @brief Trigger a logoff notification to Winbind for a specific user
1149 * @param username Name of user to remove from Winbind's list of
1151 * @param uid Uid assigned to the username
1152 * @param ccfilename Absolute path to the Krb5 credentials cache to
1157 wbcErr
wbcLogoffUser(const char *username
,
1159 const char *ccfilename
);
1162 * @brief Trigger an extended logoff notification to Winbind for a specific user
1164 * @param params A wbcLogoffUserParams structure
1165 * @param error User output details on error
1169 wbcErr
wbcLogoffUserEx(const struct wbcLogoffUserParams
*params
,
1170 struct wbcAuthErrorInfo
**error
);
1173 * @brief Change a password for a user
1175 * @param username Name of user to authenticate
1176 * @param old_password Old clear text password of user
1177 * @param new_password New clear text password of user
1181 wbcErr
wbcChangeUserPassword(const char *username
,
1182 const char *old_password
,
1183 const char *new_password
);
1186 * @brief Change a password for a user with more detailed information upon
1189 * @param params Input parameters
1190 * @param error User output details on WBC_ERR_PWD_CHANGE_FAILED
1191 * @param reject_reason New password reject reason on WBC_ERR_PWD_CHANGE_FAILED
1192 * @param policy Password policy output details on WBC_ERR_PWD_CHANGE_FAILED
1196 wbcErr
wbcChangeUserPasswordEx(const struct wbcChangePasswordParams
*params
,
1197 struct wbcAuthErrorInfo
**error
,
1198 enum wbcPasswordChangeRejectReason
*reject_reason
,
1199 struct wbcUserPasswordPolicyInfo
**policy
);
1202 * @brief Authenticate a user with cached credentials
1204 * @param *params Pointer to a wbcCredentialCacheParams structure
1205 * @param **info Pointer to a pointer to a wbcCredentialCacheInfo structure
1206 * @param **error Pointer to a pointer to a wbcAuthErrorInfo structure
1210 wbcErr
wbcCredentialCache(struct wbcCredentialCacheParams
*params
,
1211 struct wbcCredentialCacheInfo
**info
,
1212 struct wbcAuthErrorInfo
**error
);
1215 * @brief Save a password with winbind for doing wbcCredentialCache() later
1217 * @param *user Username
1218 * @param *password Password
1222 wbcErr
wbcCredentialSave(const char *user
, const char *password
);
1224 /**********************************************************
1226 **********************************************************/
1229 * @brief Resolve a NetbiosName via WINS
1231 * @param name Name to resolve
1232 * @param *ip Pointer to the ip address string
1236 wbcErr
wbcResolveWinsByName(const char *name
, char **ip
);
1239 * @brief Resolve an IP address via WINS into a NetbiosName
1241 * @param ip The ip address string
1242 * @param *name Pointer to the name
1247 wbcErr
wbcResolveWinsByIP(const char *ip
, char **name
);
1249 /**********************************************************
1250 * Trusted domain functions
1251 **********************************************************/
1254 * @brief Trigger a verification of the trust credentials of a specific domain
1256 * @param *domain The name of the domain.
1257 * @param error Output details on WBC_ERR_AUTH_ERROR
1261 wbcErr
wbcCheckTrustCredentials(const char *domain
,
1262 struct wbcAuthErrorInfo
**error
);
1265 * @brief Trigger a change of the trust credentials for a specific domain
1267 * @param *domain The name of the domain.
1268 * @param error Output details on WBC_ERR_AUTH_ERROR
1272 wbcErr
wbcChangeTrustCredentials(const char *domain
,
1273 struct wbcAuthErrorInfo
**error
);
1276 * @brief Trigger a no-op call through the NETLOGON pipe. Low-cost
1277 * version of wbcCheckTrustCredentials
1279 * @param *domain The name of the domain, only NULL for the default domain is
1280 * supported yet. Other values than NULL will result in
1281 * WBC_ERR_NOT_IMPLEMENTED.
1282 * @param error Output details on WBC_ERR_AUTH_ERROR
1286 wbcErr
wbcPingDc(const char *domain
, struct wbcAuthErrorInfo
**error
);
1288 /**********************************************************
1290 **********************************************************/
1293 * @brief Initialize a named blob and add to list of blobs
1295 * @param[in,out] num_blobs Pointer to the number of blobs
1296 * @param[in,out] blobs Pointer to an array of blobs
1297 * @param[in] name Name of the new named blob
1298 * @param[in] flags Flags of the new named blob
1299 * @param[in] data Blob data of new blob
1300 * @param[in] length Blob data length of new blob
1304 wbcErr
wbcAddNamedBlob(size_t *num_blobs
,
1305 struct wbcNamedBlob
**blobs
,
1311 #endif /* _WBCLIENT_H */