node-activedirectory
node-activedirectory copied to clipboard
Users profile picture
Is there a way to request additional fields for findUser? I would like to get the users profile picture from AD.
TIA,
Andrew
Hello,
I recently did just this. Here is my code:
config={baseDN:baseDN, url: url, username, password, attributes:{ user: [ 'dn', 'distinguishedName', 'userPrincipalName', 'sAMAccountName', 'mail', 'lockoutTime', 'whenCreated', 'pwdLastSet', 'userAccountControl', 'employeeID', 'sn', 'givenName', 'initials', 'cn', 'displayName', 'comment', 'description', 'thumbnailPhoto' ], }, entryParser:customParser}
Custom parser is the following function:
const customParser=function(entry, raw, callback){ if (raw.hasOwnProperty("thumbnailPhoto")){ entry.thumbnailPhoto = raw.thumbnailPhoto; } callback(entry) }
Hello,
Thanks for this preview answer but i want to know how to display that because when you got it. In my case i tried to get that but i couldn't display it because it is an objet (a Buffer)
Thanks.
The data schould be a byte array, you might have to transform it to base64. That schould give you the image source in a more usable form.
@swrocket Hope this helps!
var userPic = new Buffer(user["thumbnailPhoto"]).toString('base64');
Now the userPic would be the base 64 encoded image, you can send this to front end and display the image using img tag
you could refer to http://jsfiddle.net/hpP45/