©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
(PHP 4, PHP 5)
ldap_mod_del — Delete attribute values from current attributes
$link_identifier
, string $dn
, array $entry
)
Removes one or more attributes from the specified dn
.
It performs the modification at the attribute level as opposed to the object
level. Object-level deletions are done by the
ldap_delete() function.
link_identifier
An LDAP link identifier, returned by ldap_connect() .
dn
The distinguished name of an LDAP entity.
entry
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
[#1] gsgleason at gmail dot com [2015-01-26 20:03:56]
To remove all of a particular attribute, feed it an empty array.
For example, to remove all members from a group:
<?php
ldap_mod_del($ldapconn,$groupDN,array("member" => array()));
?>
[#2] bart-holland at wedefo dot nl [2013-11-07 15:27:36]
Te remove a user from a group in Apple's Open Directory, you need to also remove the members generated uid from the group.
Removing the users is as follows:
<?php
//setting variables
$ldapDN = "uid=myadmin,cn=users,dc=myserver,dc=com';
$ldapPass = "somepass";
$groupDn = 'cn=mygroup,cn=groups,dc=myserver,dc=com'
$removal = array(
"memberuid"=>"username",
"apple-group-memberguid"=>"846DE847-D73D-428D-83A8-B95B606C511B"
);
//connect and bind
$ldapconnect = ldap_connect("myserver.com",389);
ldap_bind($ldapconnect, $ldapDN, $ldapPass);
//removing member from group
ldap_mod_del($ldapconnect, $groupDn, $removal);
//unbind
ldap_unbind($ldapconnect);
?>
[#3] jonatam dot ribeiro at hotmail dot com [2013-05-07 14:44:32]
We often need to delete "objectclass" below follows a simple code to make this successful removal.
$userdataModifydelSamba = array();
$userdataModifydelSamba['objectClass'] = array();
$userdataModifydelSamba['objectClass'][0] = 'sambaSamAccount';
$userdataModifydelSamba['sambasid'] = array();
$userdataModifydelSamba['sambantpassword'] = array();
$userdataModifydelSamba['sambahomedrive'] = array();
$userdataModifydelSamba['sambadomainname'] = array();
$userdataModifydelSamba['sambaacctflags'] = array();
$userdataModifydelSamba['sambaprimarygroupsid'] = array();
$userdataModifydelSamba['sambapwdlastset'] = array();
$sucess = @ldap_mod_del($connection, $dn, $result);
if(!$sucess)
{
throw new Exception("error " . ldap_err2str(ldap_errno($connection)));
}
[#4] [2006-04-06 08:35:59]
For anyone interested in removing a user from a group, you can use ldap_mod_del() as follows:
$group = 'CN=mygroup,OU=myOU,DC=mydomain,DC=com';
$group_info['member'] = 'CN=User\, Test,CN=Users,DC=mydomain,DC=com';
ldap_mod_del($ldap, $group, $group_info);
I have tested this using Active Directory on a Win 2K3 server.
[#5] thomas dot thiel at tapgmbh dot com [2002-12-09 08:42:10]
and please don't forget:
you can't delete all attributes, when at least one is required.
[#6] JoshuaStarr at aelana dot com [2002-05-13 22:24:01]
The above example has also been proven to work in the iPlanet / Sun One Directory Server 5.0/5.1. As an example:
$attrs["mail"] = array();
ldap_mod_del($ldapConnID,$dn,$attrs);
or
$attrs["mail"] = array();
$attrs["telephonenumber"] = array();
ldap_mod_del($ldapConnID,$dn,$attrs);
This will remove all occurences of attributes in the entry specified by the dn.
[#7] ral at royal dot net [2001-08-30 08:09:40]
At least with OpenLDAP 1.2.x
to remove an attribute regardless of it's value you have to assign:
$attrs["AttributeName"]=array();
after ldap_mod_del($ds,$dn,$attrs)
all occurences of AttributeName will be removed
[#8] ral at royal dot net [2001-07-22 10:33:57]
To remove all instances of an attribute:
$entry["attrname"][]="value1";
$entry["attrname"][]="value2";
...
$entry["attrname"][]="valueN";
ldap_mod_del($ds, $dn, $entry);
[#9] twopairs at solfy dot com [2001-07-22 05:05:19]
<pre>
uid: testuser
mail: testuser@test.net
mail: testuser@somewhere.com
</pre>
How to remove the values of mail so that only the second value for mail exists:
<pre>
$entry["mail"] = "testuser@test.net";
$result = ldap_mod_del($connID, $dn, $entry);
</pre>
if you want to remove all instances of an attribute.....
==>
<pre>
$entry["mail"][0] = "testuser@test.net";
$entry["mail"][1] = "testuser@somewhere.net";
$result = ldap_mod_del($connID, $dn, $entry);
</pre>
are not?
[#10] sam_freund at yahoo dot com [2000-12-05 12:11:10]
Using ldap_modify with a blank string works if you aren't propagating your LDAP database, even though it returns the error. Still, I'd say don't do it, as it smacks of something that will be fixed in a future version.
[#11] mark at cushman dot net [2000-11-20 09:17:16]
I have found that the syntax:
$entry["mail"] = "";
Will NOT delete the mail attribute using the OpenLDAP server. You must specify the attribute value to delete it successfully, otherwise you will recieve an "Invalid Syntax" error from the server.
The error: "Inappropriate Matching" will be displayed if the attribute you are trying to delete has no equality rule in the schema. I had a problem deleting the attribute facsimilieTelephoneNumber, and it was because my core.schema file did not have an EQUALITY definition for that attribute. I copied the telephoneNumber EQUALITY rule and it worked perfectly.
[#12] arjanw at bigfoot dot com [2000-08-08 11:15:55]
To remove all instances of an attribute you can use ldap_modify with an empty value for that attribute.
$entry["mail"] = "";
$result = ldap_modify($connID, $dn, $entry);
[#13] arimus at apu dot edu [2000-04-27 19:35:42]
After a couple hours of searching and not finding anything on the ldap_mod_del function worth anything, I started trying to figure out myself what format the "array entry" parameter needed to be in. Here is what I found:
The entry array is a hash with the attribute name as the hash key and the specific value you want deleted for that attribute as the corresponding hash value.
-- Example
Current values for the attributes of of a particular entry:
uid: testuser
mail: testuser@test.net
mail: testuser@somewhere.com
How to remove the first value of mail so that only the second value for mail exists:
$entry["mail"] = "testuser@test.net";
$result = ldap_mod_del($connID, $dn, $entry);
So if you want to remove all instances of an attribute, you have to do it one by one.