ldapsearch整个活动目录没有refldap返回

时间:2015-10-07 09:53:07

标签: active-directory ldap

我正在尝试通过整个AD执行过滤的ldapsearch。但是,当我将basedn设置为我得到的域时," refldap"即使过滤器不匹配(这是我想要测试的......),查询到其他“分区”的推荐响应也是如此。

e.g。

import UIKit

class OrderViewCell: UITableViewCell {

  @IBOutlet weak var orderLabel: UILabel!
  @IBOutlet weak var lblitem: UILabel!

  @IBOutlet weak var lblquantity: UILabel!
  @IBOutlet weak var lblbp: UILabel!

}

有没有办法阻止这些推荐条目/退货?

(我试图将输出写入标记文件,然后我测试其大小...使用虚假条目,即使过滤后的查询失败,我仍然可以获得文件大小<> 0) / p>

我确实考虑过查询GC,但我想要的属性没有存储在那里(我不想添加它!)

有什么想法吗? 谢谢 大卫

2 个答案:

答案 0 :(得分:0)

我认为我找到了一种可以使用的替代品。如果我在'ldap模式'(https://technet.microsoft.com/en-us/library/cc754232.aspx)中使用RSAT dsquery.exe工具,似乎就是这样做的。

dsquery * domainroot -filter "(&(pwmResponseSet=*)(samaccountname=%USERNAME%))"

我希望这可以帮助同一条船上的某人

干杯 大卫

答案 1 :(得分:0)

如果要折叠的行很长,可以通过在ldapsearch命令中添加以下参数来防止这种情况的发生:

-o ldif-wrap=no

如果使用允许的Windows版本,则可以使用findstr

例如:

ldapsearch -o ldif-wrap=no -LLL -h 127.0.0.1 -b "dc=ad-test,dc=local" ^
    -D "cn=ldapproxy,cn=users,DC=ad-test,DC=local" ^
    -w password ^
    (&(pwmResponseSet=*)(samaccountname=notestuser))" dn | ^
    findstr /r /v /c:"^# refldap" /c:"^$" "%~1" > yourfile.ldif

或者如果您想在linux上这样做:

ldapsearch -o ldif-wrap=no -LLL -h 127.0.0.1 -b "dc=ad-test,dc=local" \
    -D "cn=ldapproxy,cn=users,DC=ad-test,DC=local" \
    -w password \
    (&(pwmResponseSet=*)(samaccountname=notestuser))" dn | \
    grep -v -e "^# refldap" -e "^$" > yourfile.ldif

这可以防止线折叠。

它也过滤掉所有以# refldap字符串开头和空行的行。

重要说明:在Windows上的^\后面不要留任何空格  在Linux上,否则它将无法正常工作。 希望对您有所帮助。

相关问题