From c330f85be88bc6e7348199d73d7d7a930c1d5c87 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date: Tue, 5 Jun 2012 02:21:49 -0500
Subject: Activate new user attributes

---
 src/libtdeldap.cpp | 69 ++++++++++++++++++++++++++++++++----------------------
 src/libtdeldap.h   |  3 +++
 2 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 3b8f2af..7c01b59 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -317,6 +317,9 @@ printf("[RAJA DEBUG 100.3] %s: %s\n\r", attr, vals[i]->bv_val);
 			else if (ldap_field == "gidNumber") {
 				userinfo.primary_gid = atoi(vals[i]->bv_val);
 			}
+			else if (ldap_field == "tdeBuiltinAccount") {
+				userinfo.tde_builtin_account = (TQString(vals[i]->bv_val).upper() == "TRUE")?true:false;
+			}
 			else if (ldap_field == "krb5KDCFlags") {
 				userinfo.status = (LDAPKRB5Flags)(atoi(vals[i]->bv_val));
 			}
@@ -404,9 +407,9 @@ printf("[RAJA DEBUG 100.3] %s: %s\n\r", attr, vals[i]->bv_val);
 			else if (ldap_field == "pager") {
 				userinfo.pagerNumber = vals[i]->bv_val;
 			}
-				// FIXME
-				// This attribute is not present in my current LDAP schema
-				// userinfo.website = vals[i]->bv_val;
+			else if (ldap_field == "websiteURL") {
+				userinfo.website = vals[i]->bv_val;
+			}
 			else if (ldap_field == "postOfficeBox") {
 				userinfo.poBox = vals[i]->bv_val;
 			}
@@ -446,22 +449,24 @@ printf("[RAJA DEBUG 100.3] %s: %s\n\r", attr, vals[i]->bv_val);
 			else if (ldap_field == "employeeNumber") {
 				userinfo.employeeNumber = vals[i]->bv_val;
 			}
-				// FIXME
-				// These two attributes are not present in my current LDAP schema
-// 						userinfo.manager = vals[i]->bv_val;
-// 						userinfo.secretary = vals[i]->bv_val;
+			else if (ldap_field == "managerName") {
+				userinfo.manager = vals[i]->bv_val;
+			}
+			else if (ldap_field == "secretaryName") {
+				userinfo.secretary = vals[i]->bv_val;
+			}
 			else if (ldap_field == "internationaliSDNNumber") {
 				userinfo.isdnNumber = vals[i]->bv_val;
 			}
-						// FIXME
-						// This attribute is not present in my current LDAP schema
-// 						userinfo.teletexID = vals[i]->bv_val;
+			else if (ldap_field == "teletexId") {
+				userinfo.teletexID = vals[i]->bv_val;
+			}
 			else if (ldap_field == "telexNumber") {
 				userinfo.telexNumber = vals[i]->bv_val;
 			}
-						// FIXME
-						// This attribute is not present in my current LDAP schema
-// 						userinfo.preferredDelivery = vals[i]->bv_val;
+			else if (ldap_field == "preferredDelivery") {
+				userinfo.preferredDelivery = vals[i]->bv_val;
+			}
 			else if (ldap_field == "destinationIndicator") {
 				userinfo.destinationIndicator = vals[i]->bv_val;
 			}
@@ -474,18 +479,18 @@ printf("[RAJA DEBUG 100.3] %s: %s\n\r", attr, vals[i]->bv_val);
 			else if (ldap_field == "preferredLanguage") {
 				userinfo.preferredLanguage = vals[i]->bv_val;
 			}
-						// FIXME
-						// This attribute is not present in my current LDAP schema
-// 						userinfo.uniqueIdentifier = vals[i]->bv_val;
+			else if (ldap_field == "locallyUniqueID") {
+				userinfo.uniqueIdentifier = vals[i]->bv_val;
+			}
 			else if (ldap_field == "businessCategory") {
 				userinfo.businessCategory = vals[i]->bv_val;
 			}
 			else if (ldap_field == "carLicense") {
 				userinfo.carLicense = vals[i]->bv_val;
 			}
-						// FIXME
-						// This attribute is not present in my current LDAP schema
-// 						userinfo.notes = vals[i]->bv_val;
+			else if (ldap_field == "notes") {
+				userinfo.notes = vals[i]->bv_val;
+			}
 			ldap_value_free_len(vals);
 		}
 		ldap_memfree(attr);
@@ -710,7 +715,7 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user) {
 		add_single_attribute_operation(mods, &i, "homePhone", user.homePhone);
 		add_single_attribute_operation(mods, &i, "mobile", user.mobilePhone);
 		add_single_attribute_operation(mods, &i, "pager", user.pagerNumber);
-// 		add_single_attribute_operation(mods, &i, "", user.website);
+		add_single_attribute_operation(mods, &i, "websiteURL", user.website);
 		add_single_attribute_operation(mods, &i, "postOfficeBox", user.poBox);
 		add_single_attribute_operation(mods, &i, "street", user.street);
 		add_single_attribute_operation(mods, &i, "postalAddress", user.address);
@@ -724,20 +729,20 @@ int LDAPManager::updateUserInfo(LDAPUserInfo user) {
 		add_single_attribute_operation(mods, &i, "roomNumber", user.roomNumber);
 		add_single_attribute_operation(mods, &i, "employeeType", user.employeeType);
 		add_single_attribute_operation(mods, &i, "employeeNumber", user.employeeNumber);
-// 		add_single_attribute_operation(mods, &i, "", user.manager);
-// 		add_single_attribute_operation(mods, &i, "", user.secretary);
+		add_single_attribute_operation(mods, &i, "managerName", user.manager);
+		add_single_attribute_operation(mods, &i, "secretaryName", user.secretary);
 		add_single_attribute_operation(mods, &i, "internationaliSDNNumber", user.isdnNumber);
-// 		add_single_attribute_operation(mods, &i, "", user.teletexID);
+		add_single_attribute_operation(mods, &i, "teletexId", user.teletexID);
 		add_single_attribute_operation(mods, &i, "telexNumber", user.telexNumber);
-// 		add_single_attribute_operation(mods, &i, "", user.preferredDelivery);
+		add_single_attribute_operation(mods, &i, "preferredDelivery", user.preferredDelivery);
 		add_single_attribute_operation(mods, &i, "destinationIndicator", user.destinationIndicator);
 		add_single_attribute_operation(mods, &i, "x121Address", user.x121Address);
 		add_single_attribute_operation(mods, &i, "displayName", user.displayName);
 		add_single_attribute_operation(mods, &i, "preferredLanguage", user.preferredLanguage);
-// 		add_single_attribute_operation(mods, &i, "", user.uniqueIdentifier);
+		add_single_attribute_operation(mods, &i, "locallyUniqueID", user.uniqueIdentifier);
 		add_single_attribute_operation(mods, &i, "businessCategory", user.businessCategory);
 		add_single_attribute_operation(mods, &i, "carLicense", user.carLicense);
-// 		add_single_attribute_operation(mods, &i, "", user.notes);
+		add_single_attribute_operation(mods, &i, "notes", user.notes);
 		LDAPMod *prevterm = mods[i];
 		mods[i] = NULL;
 
@@ -1084,6 +1089,9 @@ for(i = 0; vals[i] != NULL; i++) {
 			else if (ldap_field == "gidNumber") {
 				groupinfo.gid = atoi(vals[i]->bv_val);
 			}
+			else if (ldap_field == "tdeBuiltinAccount") {
+				groupinfo.tde_builtin_account = (TQString(vals[i]->bv_val).upper() == "TRUE")?true:false;
+			}
 			ldap_value_free_len(vals);
 		}
 		ldap_memfree(attr);
@@ -1131,6 +1139,9 @@ for(i = 0; vals[i] != NULL; i++) {
 			if (ldap_field == "creatorsName") {
 				machineinfo.creatorsName = vals[i]->bv_val;
 			}
+			else if (ldap_field == "tdeBuiltinAccount") {
+				machineinfo.tde_builtin_account = (TQString(vals[i]->bv_val).upper() == "TRUE")?true:false;
+			}
 			else if (ldap_field == "krb5KDCFlags") {
 				machineinfo.status = (LDAPKRB5Flags)(atoi(vals[i]->bv_val));
 			}
@@ -1162,7 +1173,6 @@ printf("[RAJA DEBUG 110.1] In LDAPManager::groups() bind was OK\n\r"); fflush(st
 		LDAPMessage* msg;
 		TQString ldap_base_dn = m_basedc;
 		TQString ldap_filter = "(objectClass=posixGroup)";
-		struct timeval timeout;
 		retcode = ldap_search_ext_s(m_ldap, ldap_base_dn.ascii(), LDAP_SCOPE_SUBTREE, ldap_filter.ascii(), ldap_user_and_operational_attributes, 0, NULL, NULL, NULL, 0, &msg);
 		if (retcode != LDAP_SUCCESS) {
 			KMessageBox::error(0, i18n("<qt>LDAP search failure<p>Reason: [%3] %4</qt>").arg(retcode).arg(ldap_err2string(retcode)), i18n("LDAP Error"));
@@ -1261,7 +1271,7 @@ printf("[RAJA DEBUG 140.2] The number of entries returned was %d\n\n", ldap_coun
 				TQStringList dnParts = TQStringList::split(",", dn);
 				TQString id = dnParts[0];
 				int equalsPos = id.find("=");
-				id.remove(0,id+1);
+				id.remove(0,equalsPos+1);
 printf("[RAJA DEBUG 140.3] Moving %s to relative DN %s and parent %s", dn, id.ascii(), newSuffix.ascii()); fflush(stdout);
 				retcode = ldap_rename_s(m_ldap, dn, id, newSuffix, 0, NULL, NULL);
 				if (retcode != LDAP_SUCCESS) {
@@ -1402,6 +1412,7 @@ LDAPUserInfo::LDAPUserInfo() {
 
 	uid = -1;
 	primary_gid = -1;
+	tde_builtin_account = false;
 	status = (LDAPKRB5Flags)0;
 	account_created = TQDateTime::fromString("1970-01-01T00:00:00", TQt::ISODate);
 	account_modified = TQDateTime::fromString("1970-01-01T00:00:00", TQt::ISODate);
@@ -1426,6 +1437,7 @@ LDAPGroupInfo::LDAPGroupInfo() {
 	informationValid = false;
 
 	gid = -1;
+	tde_builtin_account = false;
 }
 
 LDAPGroupInfo::~LDAPGroupInfo() {
@@ -1436,6 +1448,7 @@ LDAPMachineInfo::LDAPMachineInfo() {
 	// TQStrings are always initialized to TQString::null, so they don't need initialization here...
 	informationValid = false;
 
+	tde_builtin_account = false;
 	status = (LDAPKRB5Flags)0;
 }
 
diff --git a/src/libtdeldap.h b/src/libtdeldap.h
index f205b79..b857bec 100644
--- a/src/libtdeldap.h
+++ b/src/libtdeldap.h
@@ -108,6 +108,7 @@ class LDAPUserInfo
 		TQString shell;
 		TQString homedir;
 		gid_t primary_gid;
+		bool tde_builtin_account;
 		LDAPKRB5Flags status;			// Default active user is 586 [KRB5_ACTIVE_DEFAULT] and locked out user is 7586 [KRB5_DISABLED_ACCOUNT]
 		TQCString new_password;
 		TQDateTime account_created;
@@ -184,6 +185,7 @@ class LDAPGroupInfo
 
 		TQString name;
 		gid_t gid;
+		bool tde_builtin_account;
 		TQStringList userlist;
 };
 
@@ -199,6 +201,7 @@ class LDAPMachineInfo
 		TQString creatorsName;
 
 		TQString name;
+		bool tde_builtin_account;
 		LDAPKRB5Flags status;
 };
 
-- 
cgit v1.2.3

