Viewing 2 replies - 1 through 2 (of 2 total)
  • Do you want to send the User photo to AD or do you want to get the photo from AD and use it as the WP User photo?

    I can not help you if you are looking for the former.

    However, we use ADI to download the thumbnailPhoto attribute from AD/LDAP and store it in wp_usermeta as an octet. Then we have a very clever Bash script that take the Image data and store it as an image file on the WP server, and then updates the wp_usermeta table so the Image becomes the WP User photo.

    We did not find any other way to solve this.

    If the plugin works for you I am happy for you.

    If not then here is the magic stuff from my bash script:

    while read line
    do
    	accntname=$(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME -e "select meta_value from wp_usermeta where user_id = $line and meta_key = 'adi_samaccountname';")
    
    	id=$(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME -e "select meta_value from wp_usermeta where user_id = $line and meta_key = 'wp_user-settings-time'")
    
    	if [ -z $id ]
    	then
    		id=$(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME -e "select unix_timestamp(user_registered) from wp_users where id = $line")
    		mysql -u $DBUSR -p$DBPWD -s -N $DBNAME -e "insert ignore into wp_usermeta (user_id, meta_key, meta_value) values ($line, 'wp_user-settings-time', $id)"
    	fi
    
    	accntthmb=$(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME -e "select meta_value from wp_usermeta where user_id = $line and meta_key = 'thumbnailphoto';")
    
        if [ -n "$accntthmb" ]
    	then
    		echo $accntthmb | base64 --decode > /var/www/html/wp-content/uploads/avatars/$accntname_avatar_$id.jpg
    		chown apache:apache /var/www/html/wp-content/uploads/avatars/$accntname_avatar_$id.jpg
    
    		insertentry="https://$localip/wp-content/uploads/avatars/${accntname}_avatar_$id.jpg"
    		entrysize=${#insertentry}
    		insertstring="a:1:{s:4:\"full\";s:$entrysize:\"$insertentry\";} "
    
    		exists=$(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME  -e "select meta_value from wp_usermeta where user_id=$line and meta_key=\"simple_local_avatar\";")
    
    		if [ -n "$exists" ]
    		then
    			mysql -u$DBUSR -p$DBPWD -s -N $DBNAME  -e "update wp_usermeta set meta_value='$insertstring' where user_id=$line and meta_key='simple_local_avatar'"
    		else
    			mysql -u$DBUSR -p$DBPWD -s -N $DBNAME  -e "insert into wp_usermeta (user_id,meta_key,meta_value ) values ($line,'simple_local_avatar','$insertstring')"
    		fi
    	fi
    
    done < <(mysql -u$DBUSR -p$DBPWD -s -N $DBNAME -e "select user_id from wp_usermeta where meta_key='adi_whenchanged' and meta_value > '$lastupdate';")

    As you can see I have set a few other variables prio to the above, like $lastupdate, $DBUSR, $DBPWD, $DBNAME, $localip

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘AD Pictures’ is closed to new replies.