Thank you Daniel for your quick answer. Unfortunately i could not find
EncodeBase64 function but i have managet to get it working. 

This is my final code to insert an piture into AD. 

> procedure TForm2.Image1DblClick(Sender: TObject);
> var aList:TLDAPAttributeList;
> aAttr:TLDAPAttribute; 
> MS:TMemoryStream;
> begin
> if OpenDialog1.Execute then
> begin
> aAttr:=TLDAPAttribute.Create;
> try
> aAttr.AttributeName:='jpegPhoto;binary'; 
> 
> MS:=TMemoryStream.Create;
> MS.LoadFromFile(OpenDialog1.FileName);
> MS.Seek(0,0);
> aAttr.Add(EncodeStringBase64(StreamToString(MS)));
> Ms.Free; 
> 
> ShowMessage(BoolToStr(ldap.Modify(ldap.SearchResult[0].ObjectName,MO_Replace,aAttr),True));
> finally
> aAttr.Free;
> end;
> end;
> end; 
> 
> Thank you all.

On 2014-03-11 13:40, Daniel Donoghue wrote: 

> function EncodeFile(const FileName: string): AnsiString; 
> 
> var 
> 
> stream: TMemoryStream; 
> 
> begin 
> 
> stream := TMemoryStream.Create; 
> 
> try 
> 
> stream.LoadFromFile(Filename); 
> 
> result := EncodeBase64(stream.Memory, stream.Size); 
> 
> finally 
> 
> stream.Free; 
> 
> end; 
> 
> end; 
> 
> FROM: Marius Dalacu [mailto:mari...@mdonline.ro] 
> SENT: 11 March 2014 12:34
> TO: Ararat Synapse
> SUBJECT: Re: [Synalist] LDAPSend binary atachment - jpegPhoto 
> 
> Thank you for your answers. Using base64 unit and loading the jpg into a 
> string list then encodestringbase64 gets the job done. Now the image uploads 
> to ldap but slighty corrupted. I think that stringlist.loadfromfile is not 
> the way to go. I must read the jpeg in another way. Any ideeas? 
> 
> Thank you all. 
> 
> Sent from Samsung Mobile 
> 
> -------- Original message -------- 
> 
> From: Daniel Donoghue 
> 
> Date:11/03/2014 11:45 (GMT+02:00) 
> 
> To: Ararat Synapse 
> 
> Subject: Re: [Synalist] LDAPSend binary atachment - jpegPhoto 
> 
> Marius,
> 
> If you're working on Linux you can use the ldapsearch tool to look at all 
> your objects and see what is returned from the directory. Im sure there are 
> equivalent tools on windows.
> 
> Unfortunately im not in front of my laptop right now or I'd give you some 
> examples
> 
> With every blessing,
> -
> Daniel Donoghue 
> 
> -------------------------
> 
> FROM: Marius Dalacu
> SENT: ‎11/‎03/‎2014 10:01
> TO: Ararat Synapse
> SUBJECT: Re: [Synalist] LDAPSend binary atachment - jpegPhoto 
> 
> Thank you for your reply, the reading part is working perfectly. 
> 
> This is the code that i am using: 
> 
> LDAPATTRIB.CLEAR;
> LDAP.SEARCHCOOKIE:='';
> LDAP.SEARCH(USERDN, FALSE, '(OBJECTCLASS=*)', LDAPATTRIB);
> IF LDAP.SEARCHRESULT.COUNT = 1 THEN
>   BEGIN 
> 
>   FOR I := 0 TO LDAP.SEARCHRESULT[0].ATTRIBUTES.COUNT-1 DO
>     BEGIN 
> 
>       CASE LDAP.SEARCHRESULT[0].ATTRIBUTES[I].ATTRIBUTENAME OF
>         'SAMACCOUNTNAME' : 
> 
>         'JPEGPHOTO' :
>            BEGIN
>              MS:=TMEMORYSTREAM.CREATE;
>              LDAP.SEARCHRESULT[0].ATTRIBUTES.ITEMS[I].SAVETOSTREAM(MS);
>              MS.SEEK(0,0);
>             IMAGE1.PICTURE.LOADFROMSTREAM(MS);
>             MS.FREE; 
> 
>          END 
> 
>    END; 
> 
> So, i think that the jpegPhoto attribute is not encoded, it is the raw jpeg 
> (unless the decoding is done transparently by ldapsend). 
> 
> What else can i do, how to investigate? Why is the difference in size when i 
> load from file and save to file from attr recodrd? 
> 
> Thank you very much. 
> 
> On 2014-03-11 9:44, Lukas Gebauer wrote: 
> 
> Hi, i have successfully used ldapsend to browse my AD and to add small 
> attributes. Now i want to add the jpegPhoto attribute to some users but i am 
> facing a lot of problems. 
> 
> Please, try to reas some existing Jpeg from the LDAP and see, how it 
> 
> is encoded. Maybe it is encoded as Base64.
> 
> -- 
> 
> Lukas Gebauer.
> 
> http://synapse.ararat.cz/ [1] - Ararat Synapse - TCP/IP Lib.
> 
> http://geoget.ararat.cz/ [2] - Geocaching solution
> 
> ------------------------------------------------------------------------------
> 
> Learn Graph Databases - Download FREE O'Reilly Book
> 
> "Graph Databases" is the definitive new guide to graph databases and their
> 
> applications. Written by three acclaimed leaders in the field,
> 
> this first edition is now available. Download your free book today!
> 
> http://p.sf.net/sfu/13534_NeoTech [3]
> 
> _______________________________________________
> 
> synalist-public mailing list
> 
> synalist-public@lists.sourceforge.net
> 
> https://lists.sourceforge.net/lists/listinfo/synalist-public [4]

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech [3]

_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public [4]

 

Links:
------
[1] http://synapse.ararat.cz/
[2] http://geoget.ararat.cz/
[3] http://p.sf.net/sfu/13534_NeoTech
[4] https://lists.sourceforge.net/lists/listinfo/synalist-public
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to