I am pretty sure that you can do this through the OpenDirectory interface. See This Guide:
https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/Open_Directory/Introduction/Introduction.html#//apple_ref/doc/uid/TP40000917
Basically, you need to open an Open Directory Node (let's say / Search node), and then find ODRecord for your user, and then use:
setValue:forAttribute:error
in ODRecord to set the JPEGPhoto attribute.
If you request to use dscl from the command line for this attribute, you will see the attribute value:
dscl /Search read /Users/luser JPEGPhoto
I believe the dscl tool uses an Open Directory structure (or an older / harder to use / obsolete directory service infrastructure) to read and write user record attributes. You can read and write any other attributes using this tool and the corresponding structure. I see no reason why JPEGPhoto will be different.
The / Search Node MAY only be read (since it is a kind of meta node). Not quite sure. You may need to explicitly open the corresponding Node (for example, / Local / Default node) before you can write to the entry:
dscl /Local/Default read /Users/luser JPEGPhoto
source share