2

使用ldapsj-client模块,我正在尝试将 thumbnailPhoto 保存到文件中

const auth = async () => {

    const client = new LdapClient({ url: 'myaddomain' })
    await client.bind('someemail@domain.com.br', 'passwaord')

    const opts = {
        filter: `(sAMAccountName=credential)`,
        scope: "sub"
    }

    const s = await client.search(myBaseDN, opts)

    console.log('thumbnailPhoto', s[0].thumbnailPhoto)

}

console.log() 输出类似 '����JFIF ��C...'

我不知道如何将此二进制文件保存到文件中。当我尝试几种方法时,如此所述,不起作用。似乎来自 AD 的数据不是相同的“格式”。

我尝试将其转换为缓冲区,然后转换为 base64

const buffer = Buffer.from(s[0].thumbnailPhoto, 'binary')
var src = "data:image/png;base64," + Buffer.from(s[0].thumbnailPhoto).toString('base64')

但输出不是有效的 base64。

4

0 回答 0