locked
A constraint violation occurred - when uploading picture in Active Directory RRS feed

Answers

  • Hello, Hussain Arif

    Thank you for posting here.

    Here are the answers for your reference.

    According to your question, I understand you want to upload pictures in AD, But it fails with the error message as in the screenshot you provided.

    Based on my knowledge and test in my lab, the thumbnailPhoto attribute in the AD schema can store pictures of users. Ideally, these pictures should be 96×96 pixels and less than 10KB, though they can be up to 100KB. 

    rangLower:0
    rangUpper:102400


    I am not sure you uploaded picture in AD or in OWA. Here is my test in my lab.

    For example, I have uploaded pictures for AD users with the PS script in the following link.

    Active Directory: Add or Update a User Picture using PowerShell
    http://social.technet.microsoft.com/wiki/contents/articles/19028.active-directory-add-or-update-a-user-picture-using-powershell.aspx

    1.I have 3 pictures under C:\Windows\Wallpaper. The size of the picture named P1 is 581 KB, the size of the picture named wallpaper is 10.7 KB and the size of the picture named P2 is 6.37 KB.




    2.I have uploaded P1 (with size 581KB) for user named u6, but it fails with similar error message as you. 

    Set-ADUser u6 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\P1.jpg" -Encoding byte))}

     


    3.I have uploaded wallpaper (with size 10.7 KB) for user named u5 successfully, but the we can see error message “The octet string is larger than 8KB and will not be displayed in this box.” on attribute thumbnaiPhoto of this user.

    Set-ADUser u5 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\wallpaper.jpg" -Encoding byte))}
     

    4. I have uploaded P2 (with size 6.37 KB) for user named u7 successfully.

    Set-ADUser u7 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\P2.jpg" -Encoding byte))}

     

    For the error message you provided, it is more like that the size of the pictures we upload are too larger. So we can try to change the size of the picture you uploaded or change another picture with less than 10 KB, then upload to see if it helps.

    Hope the information above is helpful. If anything is unclear, please feel free to let us know.


    This "Directory Services" Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details. 


    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.
    Tuesday, July 21, 2020 7:37 AM

All replies

  • Hi,

    look at the schema. Here's what the attribute looks like in a vanilla installation:

    Which corresponds to https://docs.microsoft.com/en-us/windows/win32/adschema/a-thumbnailphoto Do you see the same definition in your AD?


    Evgenij Smirnov

    http://evgenij.smirnov.de

    Monday, July 20, 2020 6:33 PM
  • Hello, Hussain Arif

    Thank you for posting here.

    Here are the answers for your reference.

    According to your question, I understand you want to upload pictures in AD, But it fails with the error message as in the screenshot you provided.

    Based on my knowledge and test in my lab, the thumbnailPhoto attribute in the AD schema can store pictures of users. Ideally, these pictures should be 96×96 pixels and less than 10KB, though they can be up to 100KB. 

    rangLower:0
    rangUpper:102400


    I am not sure you uploaded picture in AD or in OWA. Here is my test in my lab.

    For example, I have uploaded pictures for AD users with the PS script in the following link.

    Active Directory: Add or Update a User Picture using PowerShell
    http://social.technet.microsoft.com/wiki/contents/articles/19028.active-directory-add-or-update-a-user-picture-using-powershell.aspx

    1.I have 3 pictures under C:\Windows\Wallpaper. The size of the picture named P1 is 581 KB, the size of the picture named wallpaper is 10.7 KB and the size of the picture named P2 is 6.37 KB.




    2.I have uploaded P1 (with size 581KB) for user named u6, but it fails with similar error message as you. 

    Set-ADUser u6 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\P1.jpg" -Encoding byte))}

     


    3.I have uploaded wallpaper (with size 10.7 KB) for user named u5 successfully, but the we can see error message “The octet string is larger than 8KB and will not be displayed in this box.” on attribute thumbnaiPhoto of this user.

    Set-ADUser u5 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\wallpaper.jpg" -Encoding byte))}
     

    4. I have uploaded P2 (with size 6.37 KB) for user named u7 successfully.

    Set-ADUser u7 -Replace @{thumbnailPhoto=([byte[]](Get-Content "C:\wallpaper\P2.jpg" -Encoding byte))}

     

    For the error message you provided, it is more like that the size of the pictures we upload are too larger. So we can try to change the size of the picture you uploaded or change another picture with less than 10 KB, then upload to see if it helps.

    Hope the information above is helpful. If anything is unclear, please feel free to let us know.


    This "Directory Services" Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details. 


    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.
    Tuesday, July 21, 2020 7:37 AM
  • Hello Daisy, 

    sorry for late reply, i was busy in testing and i got the solution as you explained above, in my case the issue was the range upper was set on 0, I’ve changed it as per your suggestion and now it starts working.

    Thank you much

     Now I’m facing another tiny issue, would be great if you can help in this too.<o:p></o:p>

    When i upload the picture in OWA directly or from exchange, the users are able to see it in OWA right side picture corner but when i uploaded the picture from AD or from Any 3rd party tool (Code two, AD photo Editor), it's only shows in that user ecp not in owa in right side coroner as well as not for other company users. 


    Hussain Arif (Manager Messaging Services)


    Thursday, July 23, 2020 9:01 AM
  • Hello,

    We can refer to the link below to see if it helps.

    How to use Active Directory user photos in Windows 10
    https://www.codetwo.com/admins-blog/use-active-directory-user-photos-windows-10/


    Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.


    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.


    Thursday, July 23, 2020 10:46 AM
  • Thank you so much for sharing the above link, the link is very helpfull but my issue doesn't cover in this link.

    In owa right bar picture is not showing but showing in that user ECP. Users are also not able to see his picture in outlook prfiles when uploaded from Direct AD via powershell. 



    Hussain Arif (Manager Messaging Services)

    Friday, July 24, 2020 4:56 AM
  • Hello,

    I am sorry for the late reply.

    It seems that if we import photo into AD attribut thumbnailPhoto for the new AD user firt time, we can see the photo on Outlook and OWA, if we change the photo in AD attribut thumbnailPhoto for the same user, it will not synced.

    We can use the Set-UserPhoto cmdlet or Outlook on the web to change the user's photo. 


    For more information we can refer to the link below.
    User photos aren't synced from the on-premises environment to Exchange Online in a hybrid deployment
    https://support.microsoft.com/en-us/help/3062745/user-photos-aren-t-synced-from-the-on-premises-environment-to-exchange


    Here is a similar case.
    OWA / OUTLOOK 2016 - Active Directory "thumbnailPhoto" not showing as expected
    https://social.technet.microsoft.com/Forums/en-US/bfc8a6f7-15d3-46e2-bcc5-70e57ca121fd/owa-outlook-2016-active-directory-quotthumbnailphotoquot-not-showing-as-expected?forum=Exch2016Adm



    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.

    Tuesday, July 28, 2020 5:49 AM
  • Thanks for your response, i was able to upload picture from this command "setuserphoto" but i want to successfully upload the same from AD or Any third party AD tool in Bulk for all comany accounts and when the upload from AD, the AD is not population the picture in owa Upper right corner. please suggest. 

    Hussain Arif (Manager Messaging Services)

    Tuesday, July 28, 2020 5:58 AM
  • Hi,

    If you use the Set-UserPhoto cmdlet for one user in AD, can you see the picture in owa Upper right corner?

    Best Regards,
    Daisy Zhou


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.

    Thursday, July 30, 2020 9:22 AM
  • Hi
    How are things going on your end? Please keep me posted on this issue. 
    If you have any further questions or concerns about this question, please let us know.
    I appreciate your time and efforts.

    Best Regards,
    Daisy Zhou

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    "Directory Services" forum will be migrating to a new home on Microsoft Q&A!

    We invite you to post new questions in the "Directory Services"  forum's new home on Microsoft Q&A!

    For more information, please refer to the sticky post.
    Monday, August 3, 2020 7:36 AM