Fix primary group set from cmdline

pull/1/head
Timothy Pearson 12 years ago
parent d969e63d2c
commit 146602d7ea

@ -216,6 +216,21 @@ int main(int argc, char *argv[])
else { else {
user.distinguishedName = "uid=" + user.name + "," + ldapmanager.basedn(); 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) { if (ldapmanager.addUserInfo(user, &errorString) == 0) {
// Modify group(s) as needed // Modify group(s) as needed
bool revoke_all = args->isSet("revokeallgroups"); 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"); printf("[ERROR] Unable to retrieve list of groups from realm controller\n\r");
return -1; return -1;
} }
LDAPGroupInfoList::Iterator it;
for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) { for (it = groupInfoList.begin(); it != groupInfoList.end(); ++it) {
LDAPGroupInfo group = *it; LDAPGroupInfo group = *it;
if ((!revoke_all) && (groupList.contains(group.name.ascii()))) { 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 != "") { if (user.new_password != "") {

Loading…
Cancel
Save