can’t figure out what is the right syntax to add an additional attributes to a LDAP entry. When authenticating i get this array:
Array
(
[0] => Array
(
[cn] => Array
(
[0] => Vit Kos
)
[shortname] => Array
(
[0] => vit.kos
)
[uid] => Array
(
[0] => vit.kos
)
[mail] => Array
(
[0] => vit.kos@email.com
)
[objectclass] => Array
(
[0] => top
[1] => person
[2] => organizationalPerson
[3] => inetOrgPerson
[4] => dominoPerson
)
[givenname] => Array
(
[0] => Vit
)
[userpassword] => Array
(
[0] => password here
)
[sn] => Array
(
[0] => Kos
)
[localadmin] => Array
(
[0] => CN=#SysHQAdmin
)
[mailaddress] => Array
(
[0] => Vit.Kos@email.com
)
[maildomain] => Array
(
[0] => EMAIL
)
[dn] => CN=Vit Kos,OU=###,O=EMAIL
)
)
need to get an additional attribute member to be like
Array (
[uid] => Array
(
[0] => vit.kos
)
[mail] => Array
(
[0] => vit.kos@email.com
)
[member] => Array
(
[0] => MEMBER HERE
)
)
Never worked with LDAP before so it’s quite confusing for me. Thanks for the answers.
To assign data to the directory item that you retrieved above, you will perform a “modify” operation with
ldap_modify(). This is assuming that the schema of your database allows an attribute calledmemberon this object – which it may not, you cannot simply add attributes to any object as and when you feel like it.Firstly, you will need to create the entry or entries that will belong to the
memberattribute, and store them in an array:In order to tell the directory which object we want to modify, we will need it’s DN. We can get this from the result of your previous search/list/read operation – the array that you show you have retrieved already (I assume this is stored in a variable called
$array):Now we have all the information we need to perform the modify operation (I assume your connected/bound LDAP resource is held in a variable called
$ds):After this,
$resultwill be a boolean indicating whether the operation was successful or not. If it was unsuccessful, you can get an error message explaining why by calling: