亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3619 | 回復(fù): 0
打印 上一主題 下一主題

[ldap] openldap訪問AD的問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2007-08-25 13:34 |只看該作者 |倒序?yàn)g覽
linux下的client訪問windows的AD,程序如下:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ldap.h>

  4. main()
  5. {
  6.         LDAP            *ld;
  7.         LDAPMessage     *res, *e;
  8.         int             i;
  9.         char            *a, *dn;
  10.         void            *ptr;
  11.         char            **vals;
  12.         char            *server = "192.168.1.161";
  13.         int group = 0, user = 0;
  14.         char *gname[256];
  15.         int gcount = 0, ucount = 0;
  16.         int j;
  17.         const char *attr[]={
  18.                 "name",
  19.                 "member",
  20.                 NULL
  21.         };

  22.         if ( (ld = ldap_open( server, LDAP_PORT )) == NULL )
  23.                 exit( 1 );
  24.         if ( ldap_simple_bind_s( ld, "test", "111222333") != LDAP_SUCCESS )
  25.         {
  26.                 ldap_perror( ld, "ldap_simple_bind_s" );
  27.                 exit( 1 );
  28.         }
  29.          if (ldap_search_s(ld, "ou=test,dc=cu,dc=com", LDAP_SCOPE_SUBTREE, NULL, NULL, 0, &res) != LDAP_SU
  30. CCESS)
  31.         {
  32.                 ldap_perror( ld, "ldap_search_s" );
  33.                 exit( 1 );
  34.         }
  35.         for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) )
  36.         {
  37.                 dn = ldap_get_dn( ld, e );
  38.                 printf( "dn: %s\n", dn );
  39.                 free( dn );
  40.                 for ( a = ldap_first_attribute( ld, e, (BerElement **)&ptr ); a != NULL; a = ldap_next_attribute( ld, e, (BerElement *)ptr )
  41. )
  42.                 {
  43.                         printf("attribute[%s]:", a);
  44.                         vals = ldap_get_values( ld, e, a );
  45.                         for ( i = 0; vals[i] != NULL; i++ )
  46.                         {
  47.                                 printf("%s\n",vals[i]);
  48.                         }
  49.                         ldap_value_free( vals );
  50.                 }
  51.         }
  52. ldap_msgfree( res );
  53. ldap_unbind( ld );
  54. }
復(fù)制代碼

可以得到所有在ou=test中的用戶,但是我想得到所有ou里面的用戶,我把程序改為:

  1. if (ldap_search_s(ld, "ou=test,dc=cu,dc=com", LDAP_SCOPE_SUBTREE, NULL, NULL, 0, &res) != LDAP_SU
  2. CCESS)
復(fù)制代碼

改為:

  1. if (ldap_search_s(ld, "dc=cu,dc=com", LDAP_SCOPE_SUBTREE, NULL, NULL, 0, &res) != LDAP_SU
  2. CCESS)
復(fù)制代碼

會一直在這里阻塞,但是利用tcpdump抓包看到AD已經(jīng)把所有的ou信息發(fā)送給了client,這是為什么呢?
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP