forked from pdavila13/consultesLdap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploadPhoto.php
49 lines (34 loc) · 1.08 KB
/
uploadPhoto.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
#IMPORTANT: no poseu les paraules de pas a aquest fitxer:
include "/etc/paraulesdepas.php";
$ldapconfig['host'] = '192.168.0.8';
#Només cal indicar el port si es diferent del port per defecte
$ldapconfig['port'] = NULL;
$ldapconfig['basedn'] = 'dc=iesebre,dc=com';
$ds=ldap_connect($ldapconfig['host'], $ldapconfig['port']);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$password=$PASSWD;
$dn="cn=admin,dc=iesebre,dc=com";
$basedn="ou=All,dc=iesebre,dc=com";
if ($bind=ldap_bind($ds, $dn, $password)) {
echo("Login correct\n");
} else {
# Error
}
$USERDN="cn=Tur AsAdmin Sergi,ou=people,ou=maninfo,ou=Personal,ou=All,dc=iesebre,dc=com";
$attrs=array();
if(class_exists('Imagick')){
$im = new Imagick('/home/sergi/Escriptori/SergiTurGosa.jpeg');
$im->setImageOpacity(1.0);
//$im->resizeImage(147,200,Imagick::FILTER_UNDEFINED,0.5,TRUE);
//$im->setCompressionQuality(90);
$im->setImageFormat('jpeg');
$attrs['jpegphoto']=$im->getImageBlob();
} else {
echo "ERROR!";
}
$ret1=ldap_mod_add($ds,$USERDN,$attrs);
if (!$ret1) {
echo "Error at ldap_mod_add: $ret1\n";
}
?>