简体   繁体   English

PHP的:ldap_add是异步的?

[英]php: ldap_add is asynchronous?

I'm developing a PHP app in which a create ldap items. 我正在开发一个在其中创建ldap项目的PHP应用程序。 And when I add an item, I need to get it right away because I need to know its creation timestamp for some purpose. 添加项目时,我需要立即获取它,因为出于某种目的,我需要知道其创建时间戳。

I then have : 然后我有:

  • ldap_add($ds, $dn, $data) ldap_add($ ds,$ dn,$ data)
  • ldap_search($ds, $root, $some_filter) ldap_search($ ds,$ root,$ some_filter)

Almost every time, I get the right result in the search, but it happens me twice that : - the right entry was created (I could check it afterward) - the search didn't find anything. 几乎每次,我都会在搜索中得到正确的结果,但两次却发生了两次:-创建了正确的条目(以后可以检查)-搜索没有找到任何东西。

After some googling, I found that there are two C functions to add an entry: ldap_add, and ldap_add_s, the first one being asynchronous. 进行一些谷歌搜索之后,我发现有两个C函数可以添加条目:ldap_add和ldap_add_s,第一个是异步的。 My best guess it that : 我最好的猜测是:

  • the PHP ldap_add calls the C function ldap_add (asynchronous) PHP ldap_add调用C函数ldap_add(异步)
  • it returns "true" to say "it's going to be right" (but not "it was right") 它返回“ true”,说“这将是正确的”(但不是“它是正确的”)
  • in some case, my search occurs when the ldap_add is still running in background, and then I get an empty result. 在某些情况下,当ldap_add仍在后台运行时发生搜索,然后得到空结果。

Would this explanation make sense? 这种解释有意义吗? Is there any other solution that wait a little bit if the search returns nothing, and try again? 如果搜索没有返回任何其他解决方案,请稍等一下,然后重试?

Best, 最好,

V. V.

No PHP use ldap_add_s : https://github.com/php/php-src/blob/master/ext/ldap/ldap.c#L1444 没有PHP使用ldap_add_shttps : //github.com/php/php-src/blob/master/ext/ldap/ldap.c#L1444

So as long as your LDAP server doesn't lie, which might happen with some multi-master configuration, your search result must contain the value you just added. 因此,只要您的LDAP服务器没有说谎(某些多主机配置可能会发生这种情况),您的搜索结果就必须包含您刚刚添加的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM