summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-03-26 08:45:39 -0500
committerTimothy Pearson <[email protected]>2013-03-26 08:45:39 -0500
commit146602d7eac63688e25fd1fcadb1c011625ee358 (patch)
treef70c4915565bb68cd60774c6612aaa9706580752
parentd969e63d2c0d827a33f68c4f5c0ec1634c390fd0 (diff)
downloadkcmldapmanager-146602d7eac63688e25fd1fcadb1c011625ee358.tar.gz
kcmldapmanager-146602d7eac63688e25fd1fcadb1c011625ee358.zip
Fix primary group set from cmdline
-rw-r--r--cmdline/main.cpp30
1 files changed, 15 insertions, 15 deletions
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 != "") {