static int samldb_generate_sAMAccountName(struct samldb_ctx *ac,
					  struct ldb_message *msg)
{
	struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
	char *name;

	/*
	 * This is currently a Samba-only behaviour, to add a trailing
	 * $ even for the generated accounts.
	 */

	if (ac->need_trailing_dollar) {
		/* Format: $000000-00000000000$ */
		name = talloc_asprintf(msg, "$%.6X-%.6X%.5X$",
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random());
	} else {
		/* Format: $000000-000000000000 */

		name = talloc_asprintf(msg, "$%.6X-%.6X%.6X",
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random());
	}
	if (name == NULL) {
		return ldb_oom(ldb);
	}
	return ldb_msg_add_steal_string(msg, "sAMAccountName", name);
}
static int samldb_generate_sAMAccountName(struct samldb_ctx *ac,
					  struct ldb_message *msg)
{
	struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
	char *name;

	 

	if (ac->need_trailing_dollar) {
		 
		name = talloc_asprintf(msg, "$%.6X-%.6X%.5X$",
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random());
	} else {
		 

		name = talloc_asprintf(msg, "$%.6X-%.6X%.6X",
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random(),
				       (unsigned int)generate_random());
	}
	if (name == NULL) {
		return ldb_oom(ldb);
	}
	return ldb_msg_add_steal_string(msg, "sAMAccountName", name);
}