Menu
Random Phoo Image
Search
Category Cloud
Releaselog | RLSLOG.net
| Oscars 2010 The Highlights WS PDTV XviD-watbath |
| Binverse - get 14 days of free Usenet access! |
| M-Zone (2010.03.10) |
| Brothers 2009 DVDRip XviD-Larceny |
| The Colbert Report (2010.03.08-2010.03.11) |
www.VCDQuality.com Klip
My GPS lost itself
| OnLive Remote Gaming Service Launches In June |
| Serendipity :o) |
| Hospitalidade Norte Americana... |
| Las Vegas...here we go! |
| Um exemplo de transparência... |
lms.ispgaya|pt ::: noticias
| Novo site! |
| Vice do major acusado de burlar idosa com terreno |
| Oh k, tenho de admitir. |
| The Dears - Who Are You, Defenders of the Universe? |
| First-Person Shooter Modified For Fire Drill Simulation |
Slashdot
Neowin.net
Blog Archives
- August 2009 (1)
- June 2009 (1)
- May 2009 (1)
- April 2009 (2)
- March 2009 (7)
- February 2009 (5)
- January 2009 (4)
- December 2008 (2)
- November 2008 (2)
- October 2008 (2)
- September 2008 (1)
- July 2008 (4)
- June 2008 (3)
- March 2008 (1)
- February 2008 (1)
- December 2007 (7)
- November 2007 (1)
- October 2007 (7)
- September 2007 (3)
- June 2007 (5)
- November 2006 (1)
- September 2006 (2)
- July 2006 (3)
- June 2006 (3)
- May 2006 (6)
- April 2006 (1)
- March 2006 (1)
coding
Vou deixar aqui uma função que pode dar jeito a alguém, visto que numa pesquisa por alto no Google não encontrei nada funcional e simples, por isso pesquisei (nunca tinha trabalhado com LDAP em php) e criei esta pequena função que devolve em binary o campo "jpegPhoto", para que assim seja possível criar a imagem.
{
$ldapserver = "ldap.exemplo.com";
$ds = ldap_connect($ldapserver);
if ($ds) {
//Alterar a var $dn para o dn do vosso ldap, aqui fica um exemplo:
$dn = "uid=".$username.",ou=Users,dc=ispgaya,dc=pt";
$filter="(objectClass= *)";
$justthese = array("jpegphoto");
$sr=ldap_read($ds, $dn, $filter, $justthese);
if (ldap_count_entries($ds, $sr)==FALSE) {
return -2;
ldap_close($ds);
} else {
$entry = ldap_first_entry($ds, $sr);
$binary = ldap_get_values_len($ds, $entry, "jpegphoto");
if ($binary==FALSE) {
return -3;
ldap_close($ds);
} else {
return $binary[0];
ldap_close($ds);
}
}
} else {
return -1;
}
}
Para quem quiser este código juntamente com um ficheiro para verem o output, podem fazer o download aqui.
