如何将属性添加到 perl 中的 LDAP 搜索结果
How to add an attribute to the result of the LDAP search in perl
我进行了 LDAP 搜索,结果我得到了条目。
在一些条目中缺少一个属性(比如 "o")。
我需要将此 "o" 属性添加到缺少它的条目中。
注意:我不需要将此值更新到 LDAP 服务器。我只需要添加此属性 "o" 以及作为搜索结果的结果变量中的值。
我有以下代码:
if($entry->exists('o')){
func($entry);//this funtion manipulates the entry
}
else{
# I need the code here to add the "o" attribute and a value to the $entry
func($entry);
}
如何将这个属性"o"添加到变量中?
我假设该条目是一个 Net::LDAP::Entry 对象?如果是这样,您应该能够通过调用 "add":
添加属性
$entry->add( 'o' => 'new value' );
因此您的示例将如下所示:
if($entry->exists('o')){
func($entry);//this funtion manipulates the entry
}
else{
$entry->add( 'o' => 'new value' );
func($entry);
}
我进行了 LDAP 搜索,结果我得到了条目。
在一些条目中缺少一个属性(比如 "o")。
我需要将此 "o" 属性添加到缺少它的条目中。
注意:我不需要将此值更新到 LDAP 服务器。我只需要添加此属性 "o" 以及作为搜索结果的结果变量中的值。
我有以下代码:
if($entry->exists('o')){
func($entry);//this funtion manipulates the entry
}
else{
# I need the code here to add the "o" attribute and a value to the $entry
func($entry);
}
如何将这个属性"o"添加到变量中?
我假设该条目是一个 Net::LDAP::Entry 对象?如果是这样,您应该能够通过调用 "add":
添加属性$entry->add( 'o' => 'new value' );
因此您的示例将如下所示:
if($entry->exists('o')){
func($entry);//this funtion manipulates the entry
}
else{
$entry->add( 'o' => 'new value' );
func($entry);
}