[YMCS/YDMP Free Trial Program]Yealink would like to offer Free Trial Program of Yealink device management service for our current eligible customers. You can see the details below.
https://www.yealink.com/ydmp-freetrial-2020


Post Reply 
 
Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LDAP picture attribute
Author Message
cptjack Offline
Member
***

Posts: 97
Joined: Jan 2014
Reputation: 8
Post: #15
RE: LDAP picture attribute
Here is a PowerShell script that will export the Users in an OU that have a thumbnailPhoto attribute set. The resulting Contact.tar and ContactData.xml files are saved to an IIS folder where the phones can download them during provisioning. The script requires 7-Zip to be installed and IIS (or another webserver) to host the 2 files. I tested it on Server 2012 R2, but I guess this will work on 2008 also.

Contacts are displayed with their photo if one of the 3 numbers match.

YealinkContacts.ps1
Code:
Import-Module ActiveDirectory  

# Full Pathnames are needed for 7-Zip. Do NOT use relative pathnames or it will not work!
$photoTempDir = "C:\Yealink\photo\"
$tarFile = "C:\Yealink\photo.tar"
$zipExe = "C:\Program Files\7-Zip\7z.exe"
$OU = "OU=Yealink,DC=testdomain,DC=int"
$xmlContactData = "C:\inetpub\wwwroot\ContactData.xml"

#### Warning: this will delete all *.jpg files in the photoTempDir
Get-Item $photoTempDir -Include "*.jpg" | Remove-Item -force

# Find all AD Users with a thumbnailPhoto
$users = Get-ADUser -Filter * -SearchBase $OU -Properties thumbnailPhoto,telephoneNumber,mobile,ipPhone | ? {$_.thumbnailPhoto}

# ContactData.xml Headers
'<?xml version="1.0" encoding="UTF-8"?>' | Out-File -FilePath $xmlContactData
'<root_contact>' | Out-File -FilePath $xmlContactData -Append


# Create the photos and ContactData files
foreach ($user in $users) {
    $name = $photoTempDir + $user.SamAccountName + ".jpg"  
    $user.thumbnailPhoto | Set-Content $name -Encoding byte

    $strLine = '    <contact'
    $strLine+= ' display_name="' + $user.name + '" '
    $strLine+= ' mobile_number="' + $user.mobile + '" '
    $strLine+= ' office_number="' + $user.telephoneNumber + '" '
    $strLine+= ' other_number="' + $user.ipPhone + '" '
    $strLine+= ' default_photo="Config:' + $user.SamAccountName + '.jpg" '
    $strLine+= 'line="0" ring="" group_id_name="" selected_photo="0" />'
    $strLine | Out-File -FilePath $xmlContactData -Append
}
'</root_contact>' | Out-File -FilePath $xmlContactData -Append


#Build the 7-Zip Command to archive the photos into photo.tar
$command = 'cmd /C "' + $zipExe + '" a "' + $tarFile + '" "' + $photoTempDir + '\*.jpg"'
Invoke-Expression -Command:$command

Included these 3 lines in your autoprovision file:
Code:
local_contact.data.url = http://192.168.0.1/ContactData.xml
local_contact.image.url = http://192.168.0.1/photo.tar
local_contact.icon.url = http://192.168.0.1/photo.tar

Please use the reputation button below if you like this post.
(This post was last modified: 10-10-2014 04:12 AM by cptjack.)
10-04-2014 01:31 AM
Find all posts by this user    like3    dislike0 Quote this message in a reply
Post Reply 


Messages In This Thread
LDAP picture attribute - gekran - 10-23-2013, 08:30 PM
RE: LDAP picture attribute - mkeuter - 10-29-2013, 05:37 PM
RE: LDAP picture attribute - gekran - 01-23-2014, 05:00 AM
RE: LDAP picture attribute - moimael - 05-13-2014, 10:43 PM
RE: LDAP picture attribute - habile - 06-04-2014, 06:16 AM
RE: LDAP picture attribute - habile - 06-17-2014, 03:56 PM
RE: LDAP picture attribute - cptjack - 08-01-2014, 03:39 AM
RE: LDAP picture attribute - cptjack - 09-30-2014, 04:13 AM
RE: LDAP picture attribute - cptjack - 10-04-2014 01:31 AM
RE: LDAP picture attribute - bsanders - 10-04-2014, 04:51 AM

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  LDAP server is unavailable Andrei9385 2 11,549 07-16-2021 08:34 PM
Last Post: nolto
  No LDAP entries from "objectClass = contact" MaksimKa 0 4,184 01-28-2020 01:35 PM
Last Post: MaksimKa
  LDAP configuration issue Vadim Volkov 1 7,081 12-04-2019 04:21 PM
Last Post: anonymous1718628087441
  No results using LDAP argh 8 25,715 10-04-2019 09:28 PM
Last Post: justingoldberg
  LDAP T23P and Yeastar ? Atontel 1 11,046 03-30-2017 01:01 PM
Last Post: Kevin_Yealink
  LDAP configuraton for Yealink T48G in Ubuntu sani390 2 9,628 03-09-2017 07:01 AM
Last Post: sani390
  LDAP only some results DeepB 2 11,725 07-10-2015 01:43 PM
Last Post: DeepB
  T46G Disable Contact Picture tsukraw 10 40,873 05-13-2015 01:11 AM
Last Post: MiKeDaDoC
  ldaps (ldap+ssl) support? tangledhelix 3 14,385 05-14-2014 03:29 PM
Last Post: Yealink Support
  LDAP No results danieljr 4 24,011 03-31-2014 07:15 PM
Last Post: CWR

Forum Jump:


User(s) browsing this thread:

Contact Us   Yealink   Return to Top   Return to Content   Lite (Archive) Mode   RSS Syndication