From 146602d7eac63688e25fd1fcadb1c011625ee358 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 26 Mar 2013 08:45:39 -0500 Subject: Fix primary group set from cmdline --- cmdline/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'cmdline') diff --git a/cmdline/main.cpp b/cmdline/main.cpp index 0650d4c..de3b1dd 100644 --- a/cmdline/main.cpp +++ b/cmdline/main.cpp @@ -216,6 +216,21 @@ int main(int argc, char *argv[]) else { user.distinguishedName = "uid=" + user.name + "," + ldapmanager.basedn(); } + bool primary_gid_found = false; + TQString primaryGroupName = args->getOption("primarygroup"); + LDAPGroupInfoList::Iterator it; + for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { + LDAPGroupInfo group = *it; + if (primaryGroupName == group.name) { + user.primary_gid = group.gid; + primary_gid_found = true; + break; + } + } + if (!primary_gid_found) { + printf("[ERROR] Invalid primary group specified\n\r"); + return -1; + } if (ldapmanager.addUserInfo(user, &errorString) == 0) { // Modify group(s) as needed bool revoke_all = args->isSet("revokeallgroups"); @@ -225,7 +240,6 @@ int main(int argc, char *argv[]) printf("[ERROR] Unable to retrieve list of groups from realm controller\n\r"); return -1; } - LDAPGroupInfoList::Iterator it; for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { LDAPGroupInfo group = *it; if ((!revoke_all) && (groupList.contains(group.name.ascii()))) { @@ -243,20 +257,6 @@ int main(int argc, char *argv[]) } } } - bool primary_gid_found = false; - TQString primaryGroupName = args->getOption("primarygroup"); - for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { - LDAPGroupInfo group = *it; - if (primaryGroupName == group.name) { - user.primary_gid = group.gid; - primary_gid_found = true; - break; - } - } - if (!primary_gid_found) { - printf("[ERROR] Invalid primary group specified\n\r"); - return -1; - } } if (user.new_password != "") { -- cgit v1.2.1