39 if (ldap_host==NULL || ldap_bind==NULL)
return;
62 decomp_url(uri, NULL, &protocol, &ldap_host->hostname, &ldap_host->port, NULL);
63 if (!strcmp((
const char*)protocol.
buf,
"ldaps")) {
64 ldap_host->useSSL =
TRUE;
74 if (ldap_bind->dnbind.buf==NULL || ldap_bind->passwd.buf==NULL) {
80 if (ldap_bind->base.buf==NULL) {
81 ldap_bind->base =
dup_Buffer(ldap_bind->dnbind);
85 if (ldap_bind->dnbind.buf!=NULL) {
90 if (ldap_bind->base.buf!=NULL) {
95 if (ldap_host->port<=0) {
96 if (ldap_host->useSSL==
TRUE) ldap_host->port = 636;
97 else ldap_host->port = 389;
102 if (param.
buf!=NULL) {
103 if (!strcasecmp((
const char*)param.
buf,
"never")) ldap_host->reqCert = LDAP_OPT_X_TLS_NEVER;
104 else if (!strcasecmp((
const char*)param.
buf,
"hard")) ldap_host->reqCert = LDAP_OPT_X_TLS_HARD;
105 else if (!strcasecmp((
const char*)param.
buf,
"demand")) ldap_host->reqCert = LDAP_OPT_X_TLS_DEMAND;
106 else if (!strcasecmp((
const char*)param.
buf,
"allow")) ldap_host->reqCert = LDAP_OPT_X_TLS_ALLOW;
107 else if (!strcasecmp((
const char*)param.
buf,
"try")) ldap_host->reqCert = LDAP_OPT_X_TLS_TRY;
131 if (ldap_host==NULL)
return NULL;
132 if (ldap_bind==NULL)
return NULL;
134 if (ldap_bind->dnbind.buf==NULL)
return NULL;
135 if (ldap_bind->passwd.buf==NULL)
return NULL;
136 if (ldap_bind->passwd.buf[0]==
'\0')
return NULL;
137 if (ldap_host->hostname.buf==NULL)
return NULL;
138 if (ldap_host->port<=0)
return NULL;
143 if (ldap_host->useSSL!=
TRUE || ldap_host->port==389) {
145 ld = ldap_init((
char*)ldap_host->hostname.buf, ldap_host->port);
151 if (ldap_host->useSSL==
TRUE) {
153 ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_host->reqCert);
154 if (ret!=LDAP_SUCCESS) {
160 int ldap_vers = LDAP_VERSION3;
161 ret = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &ldap_vers);
162 if (ret!=LDAP_SUCCESS) {
168 ret = ldap_start_tls_s(ld, NULL, NULL);
169 if (ret!=LDAP_SUCCESS) {
187 ret = ldap_initialize(&ld, (
char*)url.
buf);
189 if (ret!=LDAP_SUCCESS) {
194 ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_host->reqCert);
195 if (ret!=LDAP_SUCCESS) {
202 ret = ldap_simple_bind_s(ld, (
char*)ldap_bind->dnbind.buf, (
char*)ldap_bind->passwd.buf);
203 if (ret!=LDAP_SUCCESS) {
264 char* dn_attr[] = {
_tochar(
"distinguishedName"),
_tochar(
"commonName"), NULL};
268 if (user->base.buf==NULL) user->base =
dup_Buffer(ldap_bind->base);
272 if (user->dnbind.buf==NULL) {
280 if (user->dnbind.buf[0]==
'\0') {
287 LDAPMessage* res = NULL;
288 ldap_search_s(ld, (
char*)user->base.buf, LDAP_SCOPE_SUBTREE, (
char*)cond.
buf, dn_attr, 0, &res);
295 LDAPMessage* ent = NULL;
296 BerElement* ber = NULL;
311 ent = ldap_first_entry(ld, res);
317 attr = ldap_first_attribute(ld, ent, &ber);
324 char** dn = ldap_get_values(ld, ent, attr);
325 if (dn==NULL || *dn==NULL) {
336 if (!strncasecmp(attr,
"commonName", 10)) {
346 int ret = ldap_simple_bind_s(ld, (
const char*)dName.
buf, (
char*)user->passwd.buf);
380 if (host==NULL)
return;
384 host->useSSL =
FALSE;
385 host->reqCert = LDAP_OPT_X_TLS_HARD;
391 if (dn==NULL)
return;
401 if (host==NULL)
return;
410 if (dn==NULL)
return;
420 JBXL_LDAP_Host* host = (JBXL_LDAP_Host*)malloc(
sizeof(JBXL_LDAP_Host));
421 if (host!=NULL) memset(host, 0,
sizeof(JBXL_LDAP_Host));
430 JBXL_LDAP_Dn* dn = (JBXL_LDAP_Dn*)malloc(
sizeof(JBXL_LDAP_Dn));
431 if (dn!=NULL) memset(dn, 0,
sizeof(JBXL_LDAP_Dn));
440 if (p_host==NULL)
return;
443 if (*p_host!=NULL) free(*p_host);
450 if (p_dn==NULL)
return;
453 if (*p_dn!=NULL) free(*p_dn);
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
Buffer init_Buffer()
初期化したBuffer型変数を返す.
Buffer dup_Buffer(Buffer buf)
Buffer型変数のコピーをつくる.
int cat_Buffer(Buffer *src, Buffer *dst)
Buffer変数 srcから dstへバッファを catする.
int copy_Buffer(Buffer *src, Buffer *dst)
Buffer型変数 srcから dstへバッファをコピーする.
#define ins_s2Buffer(src, dst)
cat_b2Buffer()
#define cat_s2Buffer(src, dst)
cat_b2Buffer()
#define erase_sBuffer(b, f)
erase_bBuffer()
#define make_Buffer_bystr(str)
set_Buffer()
#define JBXL_ARGS_ERROR
不正な引数(NULLなど)
#define JBXL_LDAP_PASSWD_ERROR
ユーザ認証失敗(ユーザは存在するが,パスワードが一致しない)
#define JBXL_LDAP_NO_VAL_ERROR
エントリの属性値がない
#define JBXL_LDAP_NO_ENTRY_ERROR
エントリ情報がない
#define JBXL_LDAP_BASE_ERROR
LDAP のBASE名が不明
#define JBXL_LDAP_NO_ATTR_ERROR
エントリの属性がない
#define JBXL_LDAP_NO_USER_ERROR
ユーザ名が空白か NULL
#define JBXL_LDAP_USER_ERROR
ユーザ認証失敗(ユーザが存在しない)
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
tList * read_index_tList_file(const char *fname, char deli)
ファイルから一行ずつ読み込んで,deliを区切り文字にしてリストのキー部とデータ部に格納.
void del_all_tList(tList **pp)
リストの全ノードの削除.ポインタ ppのノードを含むリスト全体を削除する.
Buffer buffer_key_tList(tList *list, const char *key, int no)
リストの中から no番目の keyノード(ldat.key)を探し出し,ldat.valのコピーを返す.
tList * add_tList_end(tList *pp, tList *pt)
リストppの最後に リストptを追加する.