include/smbldap.h

説明を見る。
00001 /* 
00002    Unix SMB/CIFS mplementation.
00003    LDAP protocol helper functions for SAMBA
00004    Copyright (C) Gerald Carter                  2001-2003
00005     
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019    
00020 */
00021 
00022 #ifndef _SMBLDAP_H
00023 #define _SMBLDAP_H
00024 
00025 struct smbldap_state;
00026 
00027 #ifdef HAVE_LDAP
00028 
00029 /* specify schema versions between 2.2. and 3.0 */
00030 
00031 #define SCHEMAVER_SAMBAACCOUNT          1
00032 #define SCHEMAVER_SAMBASAMACCOUNT       2
00033 
00034 /* objectclass names */
00035 
00036 #define LDAP_OBJ_SAMBASAMACCOUNT        "sambaSamAccount"
00037 #define LDAP_OBJ_SAMBAACCOUNT           "sambaAccount"
00038 #define LDAP_OBJ_GROUPMAP               "sambaGroupMapping"
00039 #define LDAP_OBJ_DOMINFO                "sambaDomain"
00040 #define LDAP_OBJ_IDPOOL                 "sambaUnixIdPool"
00041 #define LDAP_OBJ_IDMAP_ENTRY            "sambaIdmapEntry"
00042 #define LDAP_OBJ_SID_ENTRY              "sambaSidEntry"
00043 #define LDAP_OBJ_TRUST_PASSWORD         "sambaTrustPassword"
00044 
00045 #define LDAP_OBJ_ACCOUNT                "account"
00046 #define LDAP_OBJ_POSIXACCOUNT           "posixAccount"
00047 #define LDAP_OBJ_POSIXGROUP             "posixGroup"
00048 #define LDAP_OBJ_OU                     "organizationalUnit"
00049 
00050 /* some generic attributes that get reused a lot */
00051 
00052 #define LDAP_ATTRIBUTE_SID              "sambaSID"
00053 #define LDAP_ATTRIBUTE_UIDNUMBER        "uidNumber"
00054 #define LDAP_ATTRIBUTE_GIDNUMBER        "gidNumber"
00055 #define LDAP_ATTRIBUTE_SID_LIST         "sambaSIDList"
00056 
00057 /* attribute map table indexes */
00058 
00059 #define LDAP_ATTR_LIST_END              0
00060 #define LDAP_ATTR_UID                   1
00061 #define LDAP_ATTR_UIDNUMBER             2
00062 #define LDAP_ATTR_GIDNUMBER             3
00063 #define LDAP_ATTR_UNIX_HOME             4
00064 #define LDAP_ATTR_PWD_LAST_SET          5
00065 #define LDAP_ATTR_PWD_CAN_CHANGE        6
00066 #define LDAP_ATTR_PWD_MUST_CHANGE       7
00067 #define LDAP_ATTR_LOGON_TIME            8
00068 #define LDAP_ATTR_LOGOFF_TIME           9
00069 #define LDAP_ATTR_KICKOFF_TIME          10
00070 #define LDAP_ATTR_CN                    11
00071 #define LDAP_ATTR_DISPLAY_NAME          12
00072 #define LDAP_ATTR_HOME_PATH             13
00073 #define LDAP_ATTR_LOGON_SCRIPT          14
00074 #define LDAP_ATTR_PROFILE_PATH          15
00075 #define LDAP_ATTR_DESC                  16
00076 #define LDAP_ATTR_USER_WKS              17
00077 #define LDAP_ATTR_USER_SID              18
00078 #define LDAP_ATTR_USER_RID              18
00079 #define LDAP_ATTR_PRIMARY_GROUP_SID     19
00080 #define LDAP_ATTR_PRIMARY_GROUP_RID     20
00081 #define LDAP_ATTR_LMPW                  21
00082 #define LDAP_ATTR_NTPW                  22
00083 #define LDAP_ATTR_DOMAIN                23
00084 #define LDAP_ATTR_OBJCLASS              24
00085 #define LDAP_ATTR_ACB_INFO              25
00086 #define LDAP_ATTR_NEXT_USERRID          26
00087 #define LDAP_ATTR_NEXT_GROUPRID         27
00088 #define LDAP_ATTR_DOM_SID               28
00089 #define LDAP_ATTR_HOME_DRIVE            29
00090 #define LDAP_ATTR_GROUP_SID             30
00091 #define LDAP_ATTR_GROUP_TYPE            31
00092 #define LDAP_ATTR_SID                   32
00093 #define LDAP_ATTR_ALGORITHMIC_RID_BASE  33
00094 #define LDAP_ATTR_NEXT_RID              34
00095 #define LDAP_ATTR_BAD_PASSWORD_COUNT    35
00096 #define LDAP_ATTR_LOGON_COUNT           36
00097 #define LDAP_ATTR_MUNGED_DIAL           37
00098 #define LDAP_ATTR_BAD_PASSWORD_TIME     38
00099 #define LDAP_ATTR_PWD_HISTORY           39
00100 #define LDAP_ATTR_SID_LIST              40
00101 #define LDAP_ATTR_MOD_TIMESTAMP         41
00102 #define LDAP_ATTR_LOGON_HOURS           42 
00103 #define LDAP_ATTR_TRUST_PASSWD_FLAGS    43
00104 #define LDAP_ATTR_SN                    44
00105 
00106 
00107 typedef struct _attrib_map_entry {
00108         int             attrib;
00109         const char      *name;
00110 } ATTRIB_MAP_ENTRY;
00111 
00112 
00113 /* structures */
00114 
00115 extern ATTRIB_MAP_ENTRY attrib_map_v22[];
00116 extern ATTRIB_MAP_ENTRY attrib_map_to_delete_v22[];
00117 extern ATTRIB_MAP_ENTRY attrib_map_v30[];
00118 extern ATTRIB_MAP_ENTRY attrib_map_to_delete_v30[];
00119 extern ATTRIB_MAP_ENTRY dominfo_attr_list[];
00120 extern ATTRIB_MAP_ENTRY groupmap_attr_list[];
00121 extern ATTRIB_MAP_ENTRY groupmap_attr_list_to_delete[];
00122 extern ATTRIB_MAP_ENTRY idpool_attr_list[];
00123 extern ATTRIB_MAP_ENTRY sidmap_attr_list[];
00124 extern ATTRIB_MAP_ENTRY trustpw_attr_list[];
00125 
00126 
00127 /* Function declarations -- not included in proto.h so we don't
00128    have to worry about LDAP structure types */
00129 
00130 NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx,
00131                       const char *location,
00132                       struct smbldap_state **smbldap_state);
00133 
00134 const char* get_attr_key2string( ATTRIB_MAP_ENTRY table[], int key );
00135 const char** get_attr_list( TALLOC_CTX *mem_ctx, ATTRIB_MAP_ENTRY table[] );
00136 void smbldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value);
00137 void smbldap_make_mod(LDAP *ldap_struct, LDAPMessage *existing,
00138                       LDAPMod ***mods,
00139                       const char *attribute, const char *newval);
00140 BOOL smbldap_get_single_attribute (LDAP * ldap_struct, LDAPMessage * entry,
00141                                    const char *attribute, char *value,
00142                                    int max_len);
00143 BOOL smbldap_get_single_pstring (LDAP * ldap_struct, LDAPMessage * entry,
00144                                  const char *attribute, pstring value);
00145 char *smbldap_get_dn(LDAP *ld, LDAPMessage *entry);
00146 int smbldap_modify(struct smbldap_state *ldap_state,
00147                    const char *dn,
00148                    LDAPMod *attrs[]);
00149 
00150 /**
00151  * Struct to keep the state for all the ldap stuff 
00152  *
00153  */
00154 
00155 struct smbldap_state {
00156         LDAP *ldap_struct;
00157         pid_t pid;
00158         time_t last_ping;
00159         /* retrive-once info */
00160         const char *uri;
00161 
00162         /* credentials */
00163         BOOL anonymous;
00164         char *bind_dn;
00165         char *bind_secret;
00166 
00167         BOOL paged_results;
00168 
00169         unsigned int num_failures;
00170 
00171         time_t last_use;
00172         smb_event_id_t event_id;
00173 
00174         struct timeval last_rebind;
00175 };
00176 
00177 /* struct used by both pdb_ldap.c and pdb_nds.c */
00178 
00179 struct ldapsam_privates {
00180         struct smbldap_state *smbldap_state;
00181 
00182         /* Former statics */
00183         LDAPMessage *result;
00184         LDAPMessage *entry;
00185         int index;
00186 
00187         const char *domain_name;
00188         DOM_SID domain_sid;
00189 
00190         /* configuration items */
00191         int schema_ver;
00192 
00193         char *domain_dn;
00194 
00195         /* Is this NDS ldap? */
00196         int is_nds_ldap;
00197 
00198         /* ldap server location parameter */
00199         char *location;
00200 };
00201 
00202 /* Functions shared between pdb_ldap.c and pdb_nds.c. */
00203 NTSTATUS pdb_init_ldapsam_compat( struct pdb_methods **pdb_method, const char *location);
00204 void private_data_free_fn(void **result);
00205 int ldapsam_search_suffix_by_name(struct ldapsam_privates *ldap_state,
00206                                   const char *user,
00207                                   LDAPMessage ** result,
00208                                   const char **attr);
00209 NTSTATUS pdb_init_ldapsam( struct pdb_methods **pdb_method, const char *location);
00210 const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver );
00211 
00212 char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry,
00213                                        const char *attribute,
00214                                        TALLOC_CTX *mem_ctx);
00215 void talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result);
00216 void talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod);
00217 const char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld,
00218                               LDAPMessage *entry);
00219 
00220 
00221 #endif  /* HAVE_LDAP */
00222 
00223 #define LDAP_CONNECT_DEFAULT_TIMEOUT   15
00224 #define LDAP_PAGE_SIZE 1024
00225 
00226 #endif  /* _SMBLDAP_H */

Sambaに対してSat Aug 29 21:22:57 2009に生成されました。  doxygen 1.4.7