wbclient.h

Go to the documentation of this file.
00001 /*
00002    Unix SMB/CIFS implementation.
00003 
00004    Winbind client API
00005 
00006    Copyright (C) Gerald (Jerry) Carter 2007
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 3 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public License
00019    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #ifndef _WBCLIENT_H
00023 #define _WBCLIENT_H
00024 
00025 #include <pwd.h>
00026 
00027 /* Define error types */
00028 
00029 /**
00030  *  @brief Status codes returned from wbc functions
00031  **/
00032 
00033 enum _wbcErrType {
00034         WBC_ERR_SUCCESS = 0,    /**< Successful completion **/
00035         WBC_ERR_UNKNOWN_FAILURE,/**< General failure **/
00036         WBC_ERR_NO_MEMORY,      /**< Memory allocation error **/
00037         WBC_ERR_INVALID_SID,    /**< Invalid SID format **/
00038         WBC_ERR_INVALID_PARAM,  /**< An Invalid parameter was supplied **/
00039         WBC_ERR_WINBIND_NOT_AVAILABLE,   /**< Winbind daemon is not available **/
00040         WBC_ERR_DOMAIN_NOT_FOUND,        /**< Domain is not trusted or cannot be found **/
00041         WCB_INVALID_RESPONSE,        /**< Winbind returned an invalid response **/
00042 };
00043 
00044 typedef enum _wbcErrType wbcErr;
00045 
00046 char *wbcErrorString(wbcErr error);
00047 
00048 /*
00049  * Data types used by the Winbind Client API
00050  */
00051 
00052 #ifndef MAXSUBAUTHS
00053 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
00054 #endif
00055 
00056 /**
00057  *  @brief Windows Security Identifier
00058  *
00059  **/
00060 
00061 struct wbcDomainSid {
00062         uint8_t   sid_rev_num;
00063         uint8_t   num_auths;
00064         uint8_t   id_auth[6];
00065         uint32_t  sub_auths[MAXSUBAUTHS];
00066 };
00067 
00068 /**
00069  * @brief Security Identifier type
00070  **/
00071 
00072 enum wbcSidType {
00073         WBC_SID_NAME_USE_NONE=0,
00074         WBC_SID_NAME_USER=1,
00075         WBC_SID_NAME_DOM_GRP=2,
00076         WBC_SID_NAME_DOMAIN=3,
00077         WBC_SID_NAME_ALIAS=4,
00078         WBC_SID_NAME_WKN_GRP=5,
00079         WBC_SID_NAME_DELETED=6,
00080         WBC_SID_NAME_INVALID=7,
00081         WBC_SID_NAME_UNKNOWN=8,
00082         WBC_SID_NAME_COMPUTER=9
00083 };
00084 
00085 /**
00086  * @brief Domain Information
00087  **/
00088 
00089 struct wbcDomainInfo {
00090         char *short_name;
00091         char *dns_name;
00092         struct wbcDomainSid sid;
00093         uint32_t flags;
00094         uint32_t seqnum;
00095 };
00096 
00097 /* wbcDomainInfo->flags */
00098 
00099 #define WBC_DOMINFO_NATIVE            0x00000001
00100 #define WBC_DOMINFO_AD                0x00000002
00101 #define WBC_DOMINFO_PRIMARY           0x00000004
00102 
00103 /*
00104  * Utility functions for dealing with SIDs
00105  */
00106 
00107 wbcErr wbcSidToString(const struct wbcDomainSid *sid,
00108                       char **sid_string);
00109 
00110 wbcErr wbcStringToSid(const char *sid_string,
00111                       struct wbcDomainSid *sid);
00112 
00113 wbcErr wbcPing(void);
00114 
00115 /*
00116  * Name/SID conversion
00117  */
00118 
00119 wbcErr wbcLookupName(const char *dom_name,
00120                      const char *name,
00121                      struct wbcDomainSid *sid,
00122                      enum wbcSidType *name_type);
00123 
00124 wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
00125                     char **domain,
00126                     char **name,
00127                     enum wbcSidType *name_type);
00128 
00129 wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid, 
00130                      int num_rids, 
00131                      uint32_t *rids,
00132                      const char **domain_name,
00133                      const char ***names, 
00134                      enum wbcSidType **types);
00135 
00136 /*
00137  * SID/uid/gid Mappings
00138  */
00139 
00140 wbcErr wbcSidToUid(const struct wbcDomainSid *sid,
00141                    uid_t *puid);
00142 
00143 wbcErr wbcUidToSid(uid_t uid,
00144                    struct wbcDomainSid *sid);
00145 
00146 wbcErr wbcSidToGid(const struct wbcDomainSid *sid,
00147                    gid_t *pgid);
00148 
00149 wbcErr wbcGidToSid(gid_t gid,
00150                    struct wbcDomainSid *sid);
00151 
00152 wbcErr wbcAllocateUid(uid_t *puid);
00153 
00154 wbcErr wbcAllocateGid(uid_t *pgid);
00155 
00156 
00157 
00158 /*
00159  * Lookup Domain information
00160  */
00161 
00162 wbcErr wbcDomainInfo(const char *domain, 
00163                      struct wbcDomainInfo *info);
00164 
00165 wbcErr wbcDomainSequenceNumbers(void);
00166 
00167 
00168 #endif      /* _WBCLIENT_H */

Generated on Fri Sep 7 16:31:10 2007 for Samba by  doxygen 1.5.0