From f18baf461d242485c36f50c94561bbd07b909ac0 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date: Tue, 30 Sep 2025 16:53:44 -0500
Subject: Add jpegPhoto LDAP attribute to LDAPUserInfo object

---
 src/libtdeldap.cpp | 6 +++++-
 src/libtdeldap.h   | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index b9b8498..197f7c0 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -707,6 +707,9 @@ LDAPUserInfo LDAPManager::parseLDAPUserRecord(LDAPMessage* entry) {
 			else if (ldap_field == "businessCategory") {
 				userinfo.businessCategory = vals[i]->bv_val;
 			}
+			else if (ldap_field == "jpegPhoto") {
+				userinfo.profileAvatar.duplicate(vals[i]->bv_val, vals[i]->bv_len);
+			}
 			else if (ldap_field == "carLicense") {
 				userinfo.carLicense = vals[i]->bv_val;
 			}
@@ -1138,7 +1141,7 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user, TQString *errstr) {
 
 		// Assemble the LDAPMod structure
 		// We will replace any existing attributes with the new values
-		int number_of_parameters = 49;				// 49 primary attributes
+		int number_of_parameters = 50;				// 50 primary attributes
 		LDAPMod *mods[number_of_parameters+1];
 		set_up_attribute_operations(mods, number_of_parameters);
 
@@ -1198,6 +1201,7 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user, TQString *errstr) {
 		add_single_attribute_operation(mods, &i, "preferredLanguage", user.preferredLanguage);
 		add_single_attribute_operation(mods, &i, "locallyUniqueID", user.uniqueIdentifier);
 		add_single_attribute_operation(mods, &i, "businessCategory", user.businessCategory);
+		add_single_binary_attribute_operation(mods, &i, "jpegPhoto", user.profileAvatar);
 		add_single_attribute_operation(mods, &i, "carLicense", user.carLicense);
 		add_single_attribute_operation(mods, &i, "notes", user.notes);
 		add_single_binary_attribute_operation(mods, &i, "krb5ExtendedAttributes", acl_asn1_data);
diff --git a/src/libtdeldap.h b/src/libtdeldap.h
index d36f346..d97003b 100644
--- a/src/libtdeldap.h
+++ b/src/libtdeldap.h
@@ -321,6 +321,7 @@ class TDE_EXPORT LDAPUserInfo
 		TQString mobilePhone;
 		TQString pagerNumber;
 		TQString website;
+		TQByteArray profileAvatar;
 
 		// Page 2
 		TQString poBox;
-- 
cgit v1.2.3

