0 votes

Hello,

When running the supplied script for importing a user photo into AD we encounter the following error:

Exception calling "SetInfo" with "0" argument(s): "A value for the attribute was not in the acceptable range of values. (Server: example.local)" Stack trace: at <ScriptBlock>, <No file>: line 13

(domain name changed from original error message)

PS script imported from here: https://www.adaxes.com/script-repository/import-user-photo-s244.htm

Thank you for your assistance!

by (110 points)

1 Answer

0 votes
by (3.6k points)

Hello,

This issue occurs because the photo is too large. The maximum size of a user’s photo is 100 kilobytes, and this limitation comes from Active Directory, not from Adaxes. You need to downscale your photos before uploading them to Active Directory using a Business Rule Before updating a user. For details on how to do this, please, check out this script from our repository: https://www.adaxes.com/script-repository/optimize-user-photo-s362.htm.

Also, you need to use the below version of the script to import user photos:

$picturePath = "\\SERVER\Share\%username%.png"  # TODO: modify me

# Check whether the picture file exists
if(!(Test-Path -Path $picturePath))
{
    $Context.LogMessage("File does not exist '$picturePath'.", "Error")
    return
}

# Pipleline bind to the user 
$user = $Context.BindToObjectByDNEx("%distinguishedName%", $True)

# Update picture
[Byte[]]$pictureBytes = Get-Content $picturePath -Encoding Byte
$user.Put("thumbnailPhoto", $pictureBytes)
$user.SetInfo()

The reason is that the operation has to be passed through Adaxes pipeline for the Business Rule Before updating a user to trigger.

Related questions

0 votes
1 answer

Trying to test importing users via CSV. Running into the following error -- Error: The input object cannot be bound to any parameters for the command either because the command does ... in the Powershell script, but no luck -- Here's my scheduled task --

asked Apr 10 by msinger (210 points)
0 votes
1 answer

Hi, I'm following the guide about scheduling a user import from a CSV file: Schedule Import of Users from CSV but I get the following error: *"The input object cannot ... &lt;ScriptBlock&gt;, &lt;No file&gt;: line 7". Any help would be much appreciated. Dario

asked Dec 17, 2019 by winstonsmith (40 points)
0 votes
1 answer

I need to use the bulk import to import ~60 users. I am trying to do 1 test account first to ensure everything works, ... adm-CustomAttributeDate1, physicalDeliveryOffice, company, department, manager, title, adm-CustomAttributeText5, ChangePasswordAtLogon

asked Apr 9, 2018 by ScottGriff (400 points)
0 votes
1 answer

I'm looking at this onliner Set-AdmUser -Identity $DN -Replace @{AADPHoto = $photoBytes} -AdaxesService localhost -Server. I get an illegal operation error. Wondering what I ... the photo in AD and Azure at the same time to avoid waiting for synchronization.

asked Jan 30 by mightycabal (1.0k points)
0 votes
1 answer

I have problem to connect mysql to adaxes, what adaxes is support mysql or not suport mysql. can you give a sample script to connect adaxes to mysql?

asked Jan 5, 2022 by systech (100 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users