* Additionally, Samba collapses multiple spaces, and Windows doesn't.
*/
struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
- size_t i;
+ const char *inv = NULL;
- for (i = 0; name[i] != '\0'; i++) {
- uint8_t c = name[i];
- const char *p = NULL;
+ inv = strstr_for_invalid_account_characters(name);
+ if (inv != NULL) {
+ char c = *inv;
- if (c < 32 || c == 127) {
+ if (c == '\0') {
ldb_asprintf_errstring(
ldb,
- "samldb: sAMAccountName contains invalid "
- "0x%.2x character\n", c);
+ "samldb: sAMAccountName is empty\n");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- p = strchr("\"[]:;|=+*?<>/\\,", c);
- if (p != NULL) {
+
+ if (c == '.') {
+ ldb_asprintf_errstring(
+ ldb,
+ "samldb: sAMAccountName ends with '.'");
+ return LDB_ERR_CONSTRAINT_VIOLATION;
+ }
+
+ if (isprint(c)) {
ldb_asprintf_errstring(
ldb,
"samldb: sAMAccountName contains invalid "
"'%c' character\n", c);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- }
- if (i == 0) {
ldb_asprintf_errstring(
ldb,
- "samldb: sAMAccountName is empty\n");
+ "samldb: sAMAccountName contains invalid "
+ "0x%.2x character\n", c);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- if (name[i - 1] == '.') {
- ldb_asprintf_errstring(
- ldb,
- "samldb: sAMAccountName ends with '.'");
- return LDB_ERR_CONSTRAINT_VIOLATION;
- }
return LDB_SUCCESS;
}