2 backend code for provisioning a Samba4 server
3 Copyright Andrew Tridgell 2005
4 Released under the GNU GPL v2 or later
10 return true if the current install seems to be OK
12 function install_ok(session_info, credentials)
14 var lp = loadparm_init();
16 ldb.session_info = session_info;
17 ldb.credentials = credentials;
18 if (lp.get("realm") == "") {
21 var ok = ldb.connect(lp.get("sam database"));
25 var res = ldb.search("(cn=Administrator)");
26 if (res.length != 1) {
33 find a user or group from a list of possibilities
38 assert(arguments.length >= 2);
39 var nssfn = arguments[0];
40 for (i=1;i<arguments.length;i++) {
41 if (nssfn(arguments[i]) != undefined) {
45 printf("Unable to find user/group for %s\n", arguments[1]);
46 assert(i<arguments.length);
50 add a foreign security principle
52 function add_foreign(ldb, subobj, sid, desc)
55 dn: CN=%s,CN=ForeignSecurityPrincipals,%s
57 objectClass: foreignSecurityPrincipal
60 sid, subobj.BASEDN, desc);
61 /* deliberately ignore errors from this, as the records may
68 setup a mapping between a sam name and a unix name
70 function setup_name_mapping(info, ldb, sid, unixname)
72 var attrs = new Array("dn");
73 var res = ldb.search(sprintf("objectSid=%s", sid),
74 info.subobj.BASEDN, ldb.SCOPE_SUBTREE, attrs);
75 if (res.length != 1) {
76 info.message("Failed to find record for objectSid %s\n", sid);
86 var ok = ldb.modify(mod);
88 info.message("name mapping for %s failed - %s\n",
89 sid, ldb.errstring());
96 return current time as a nt time string
100 return "" + sys.nttime();
104 return current time as a ldap time string
108 return sys.ldaptime(sys.nttime());
112 return a date string suitable for a dns zone serial number
114 function datestring()
116 var t = sys.ntgmtime(sys.nttime());
117 return sprintf("%04u%02u%02u%02u",
118 t.tm_year+1900, t.tm_mon+1, t.tm_mday, t.tm_hour);
126 var list = sys.interfaces();
132 return first part of hostname
136 var s = split(".", sys.hostname());
140 /* the ldb is in bad shape, possibly due to being built from an
141 incompatible previous version of the code, so delete it
143 function ldb_delete(ldb)
145 println("Deleting " + ldb.filename);
146 var lp = loadparm_init();
147 sys.unlink(sprintf("%s/%s", lp.get("private dir"), ldb.filename));
148 ldb.transaction_cancel();
150 var ok = ldb.connect(ldb.filename);
151 ldb.transaction_start();
156 erase an ldb, removing all records
158 function ldb_erase(ldb)
162 /* delete the specials */
163 ldb.del("@INDEXLIST");
164 ldb.del("@ATTRIBUTES");
165 ldb.del("@SUBCLASSES");
167 ldb.del("@PARTITION");
168 ldb.del("@KLUDGEACL");
171 attrs = new Array("dn");
173 var res = ldb.search("(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
175 if (typeof(res) == "undefined") {
179 for (i=0;i<res.length;i++) {
183 var res = ldb.search("(&(|(objectclass=*)(dn=*))(!(dn=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
184 if (res.length != 0) {
188 assert(res.length == 0);
192 erase an ldb, removing all records
194 function ldb_erase_partitions(info, ldb, ldapbackend)
196 var rootDSE_attrs = new Array("namingContexts");
197 var lp = loadparm_init();
200 var res = ldb.search("(objectClass=*)", "", ldb.SCOPE_BASE, rootDSE_attrs);
201 assert(typeof(res) != "undefined");
202 assert(res.length == 1);
203 if (typeof(res[0].namingContexts) == "undefined") {
206 for (j=0; j<res[0].namingContexts.length; j++) {
207 var anything = "(|(objectclass=*)(dn=*))";
208 var attrs = new Array("dn");
209 var basedn = res[0].namingContexts[j];
211 var previous_remaining = 1;
212 var current_remaining = 0;
214 if (ldapbackend && (basedn == info.subobj.BASEDN)) {
215 /* Only delete objects that were created by provision */
216 anything = "(objectcategory=*)";
219 for (k=0; k < 10 && (previous_remaining != current_remaining); k++) {
221 var res2 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
223 if (typeof(res2) == "undefined") {
224 info.message("ldb search failed: " + ldb.errstring() + "\n");
227 previous_remaining = current_remaining;
228 current_remaining = res2.length;
229 for (i=0;i<res2.length;i++) {
233 var res3 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
234 if (typeof(res3) == "undefined") {
235 info.message("ldb search failed: " + ldb.errstring() + "\n");
238 if (res3.length != 0) {
239 info.message("Failed to delete all records under " + basedn + ", " + res3.length + " records remaining\n");
245 function open_ldb(info, dbname, erase)
247 var ldb = ldb_init();
248 ldb.session_info = info.session_info;
249 ldb.credentials = info.credentials;
250 ldb.filename = dbname;
252 var connect_ok = ldb.connect(dbname);
254 var lp = loadparm_init();
255 sys.unlink(sprintf("%s/%s", lp.get("private dir"), dbname));
256 connect_ok = ldb.connect(dbname);
260 ldb.transaction_start();
270 setup a ldb in the private dir
272 function setup_add_ldif(ldif, info, ldb, failok)
274 var lp = loadparm_init();
275 var src = lp.get("setup directory") + "/" + ldif;
277 var data = sys.file_load(src);
278 data = substitute_var(data, info.subobj);
280 var add_ok = ldb.add(data);
282 info.message("ldb load failed: " + ldb.errstring() + "\n");
290 function setup_modify_ldif(ldif, info, ldb, failok)
292 var lp = loadparm_init();
293 var src = lp.get("setup directory") + "/" + ldif;
295 var data = sys.file_load(src);
296 data = substitute_var(data, info.subobj);
298 var mod_ok = ldb.modify(data);
300 info.message("ldb load failed: " + ldb.errstring() + "\n");
309 function setup_ldb(ldif, info, dbname)
314 if (arguments.length >= 4) {
315 erase = arguments[3];
317 if (arguments.length == 5) {
318 failok = arguments[4];
320 var ldb = open_ldb(info, dbname, erase);
321 if (setup_add_ldif(ldif, info, ldb, failok)) {
322 var commit_ok = ldb.transaction_commit();
324 info.message("ldb commit failed: " + ldb.errstring() + "\n");
331 setup a ldb in the private dir
333 function setup_ldb_modify(ldif, info, ldb)
335 var lp = loadparm_init();
337 var src = lp.get("setup directory") + "/" + ldif;
339 var data = sys.file_load(src);
340 data = substitute_var(data, info.subobj);
342 var mod_ok = ldb.modify(data);
344 info.message("ldb load failed: " + ldb.errstring() + "\n");
351 setup a file in the private dir
353 function setup_file(template, message, fname, subobj)
355 var lp = loadparm_init();
357 var src = lp.get("setup directory") + "/" + template;
361 var data = sys.file_load(src);
362 data = substitute_var(data, subobj);
364 ok = sys.file_save(f, data);
366 message("failed to create file: " + f + "\n");
371 function provision_default_paths(subobj)
373 var lp = loadparm_init();
374 var paths = new Object();
375 paths.smbconf = lp.get("config file");
376 paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
377 paths.hklm = "hklm.ldb";
378 paths.hkcu = "hkcu.ldb";
379 paths.hkcr = "hkcr.ldb";
380 paths.hku = "hku.ldb";
381 paths.hkpd = "hkpd.ldb";
382 paths.hkpt = "hkpt.ldb";
383 paths.samdb = lp.get("sam database");
384 paths.secrets = "secrets.ldb";
385 paths.dns = lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".zone";
386 paths.winsdb = "wins.ldb";
387 paths.ldap_basedn_ldif = lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".ldif";
393 setup reasonable name mappings for sam names to unix names
395 function setup_name_mappings(info, ldb)
397 var lp = loadparm_init();
398 var attrs = new Array("objectSid");
399 var subobj = info.subobj;
401 res = ldb.search("objectSid=*", subobj.BASEDN, ldb.SCOPE_BASE, attrs);
402 assert(res.length == 1 && res[0].objectSid != undefined);
403 var sid = res[0].objectSid;
405 /* add some foreign sids if they are not present already */
406 add_foreign(ldb, subobj, "S-1-5-7", "Anonymous");
407 add_foreign(ldb, subobj, "S-1-1-0", "World");
408 add_foreign(ldb, subobj, "S-1-5-2", "Network");
409 add_foreign(ldb, subobj, "S-1-5-18", "System");
410 add_foreign(ldb, subobj, "S-1-5-11", "Authenticated Users");
412 /* some well known sids */
413 setup_name_mapping(info, ldb, "S-1-5-7", subobj.NOBODY);
414 setup_name_mapping(info, ldb, "S-1-1-0", subobj.NOGROUP);
415 setup_name_mapping(info, ldb, "S-1-5-2", subobj.NOGROUP);
416 setup_name_mapping(info, ldb, "S-1-5-18", subobj.ROOT);
417 setup_name_mapping(info, ldb, "S-1-5-11", subobj.USERS);
418 setup_name_mapping(info, ldb, "S-1-5-32-544", subobj.WHEEL);
419 setup_name_mapping(info, ldb, "S-1-5-32-545", subobj.USERS);
420 setup_name_mapping(info, ldb, "S-1-5-32-546", subobj.NOGROUP);
421 setup_name_mapping(info, ldb, "S-1-5-32-551", subobj.BACKUP);
423 /* and some well known domain rids */
424 setup_name_mapping(info, ldb, sid + "-500", subobj.ROOT);
425 setup_name_mapping(info, ldb, sid + "-518", subobj.WHEEL);
426 setup_name_mapping(info, ldb, sid + "-519", subobj.WHEEL);
427 setup_name_mapping(info, ldb, sid + "-512", subobj.WHEEL);
428 setup_name_mapping(info, ldb, sid + "-513", subobj.USERS);
429 setup_name_mapping(info, ldb, sid + "-520", subobj.WHEEL);
436 provision samba4 - caution, this wipes all existing data!
438 function provision(subobj, message, blank, paths, session_info, credentials, ldapbackend)
440 var lp = loadparm_init();
441 var sys = sys_init();
442 var info = new Object();
445 some options need to be upper/lower case
447 subobj.REALM = strupper(subobj.REALM);
448 subobj.HOSTNAME = strlower(subobj.HOSTNAME);
449 subobj.DOMAIN = strupper(subobj.DOMAIN);
450 assert(valid_netbios_name(subobj.DOMAIN));
451 subobj.NETBIOSNAME = strupper(subobj.HOSTNAME);
452 assert(valid_netbios_name(subobj.NETBIOSNAME));
453 var rdns = split(",", subobj.BASEDN);
454 subobj.RDN_DC = substr(rdns[0], strlen("DC="));
456 if (subobj.DOMAINGUID != undefined) {
457 subobj.DOMAINGUID_MOD = sprintf("replace: objectGUID\nobjectGUID: %s\n-", subobj.DOMAINGUID);
459 subobj.DOMAINGUID_MOD = "";
462 if (subobj.HOSTGUID != undefined) {
463 subobj.HOSTGUID_ADD = sprintf("objectGUID: %s", subobj.HOSTGUID);
465 subobj.HOSTGUID_ADD = "";
468 info.subobj = subobj;
469 info.message = message;
470 info.credentials = credentials;
471 info.session_info = session_info;
473 /* only install a new smb.conf if there isn't one there already */
474 var st = sys.stat(paths.smbconf);
475 if (st == undefined) {
476 message("Setting up smb.conf\n");
477 setup_file("provision.smb.conf", info.message, paths.smbconf, subobj);
480 /* only install a new shares config db if there is none */
481 st = sys.stat(paths.shareconf);
482 if (st == undefined) {
483 message("Setting up share.ldb\n");
484 setup_ldb("share.ldif", info, paths.shareconf);
486 message("Setting up secrets.ldb\n");
487 setup_ldb("secrets.ldif", info, paths.secrets);
488 message("Setting up keytabs\n");
489 var keytab_ok = credentials_update_all_keytabs();
491 message("Setting up hklm.ldb\n");
492 setup_ldb("hklm.ldif", info, paths.hklm);
494 message("Setting up sam.ldb partitions\n");
495 /* Also wipes the database */
496 setup_ldb("provision_partitions.ldif", info, paths.samdb);
498 var samdb = open_ldb(info, paths.samdb, false);
500 message("Setting up sam.ldb attributes\n");
501 setup_add_ldif("provision_init.ldif", info, samdb, false);
502 message("Erasing data from partitions\n");
503 ldb_erase_partitions(info, samdb, ldapbackend);
505 message("Adding baseDN: " + subobj.BASEDN + " (permitted to fail)\n");
506 var add_ok = setup_add_ldif("provision_basedn.ldif", info, samdb, true);
507 message("Modifying baseDN: " + subobj.BASEDN + "\n");
508 var modify_ok = setup_ldb_modify("provision_basedn_modify.ldif", info, samdb);
511 message("Failed to both add and modify " + subobj.BASEDN + " in target " + subobj.LDAPBACKEND + "\n");
512 message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n");
517 message("Setting up sam.ldb Samba4 schema\n");
518 setup_add_ldif("schema_samba4.ldif", info, samdb, false);
519 message("Setting up sam.ldb AD schema\n");
520 setup_add_ldif("schema.ldif", info, samdb, false);
522 // (hack) Reload, now we have the schema loaded.
523 var commit_ok = samdb.transaction_commit();
525 info.message("samdb commit failed: " + samdb.errstring() + "\n");
530 samdb = open_ldb(info, paths.samdb, false);
532 message("Setting up display specifiers\n");
533 setup_add_ldif("display_specifiers.ldif", info, samdb, false);
534 message("Setting up sam.ldb templates\n");
535 setup_add_ldif("provision_templates.ldif", info, samdb, false);
537 message("Adding users container (permitted to fail)\n");
538 var add_ok = setup_add_ldif("provision_users_add.ldif", info, samdb, true);
539 message("Modifying users container\n");
540 var modify_ok = setup_ldb_modify("provision_help_users_mod.ldif", info, samdb);
543 message("Failed to both add and modify the users container\n");
548 message("Adding computers container (permitted to fail)\n");
549 var add_ok = setup_add_ldif("provision_computers_add.ldif", info, samdb, true);
550 message("Modifying computers container\n");
551 var modify_ok = setup_ldb_modify("provision_computers_modify.ldif", info, samdb);
554 message("Failed to both add and modify the computers container\n");
560 message("Setting up sam.ldb data\n");
561 setup_add_ldif("provision.ldif", info, samdb, false);
562 message("Setting up sam.ldb configuration data\n");
563 setup_add_ldif("provision_configuration.ldif", info, samdb, false);
565 if (blank != false) {
566 message("Setting up sam.ldb index\n");
567 setup_add_ldif("provision_index.ldif", info, samdb, false);
569 var commit_ok = samdb.transaction_commit();
571 info.message("ldb commit failed: " + samdb.errstring() + "\n");
577 // message("Activate schema module");
578 // setup_modify_ldif("schema_activation.ldif", info, samdb, false);
580 // // (hack) Reload, now we have the schema loaded.
581 // var commit_ok = samdb.transaction_commit();
583 // info.message("samdb commit failed: " + samdb.errstring() + "\n");
584 // assert(commit_ok);
588 // samdb = open_ldb(info, paths.samdb, false);
590 message("Setting up sam.ldb users and groups\n");
591 setup_add_ldif("provision_users.ldif", info, samdb, false);
593 if (setup_name_mappings(info, samdb) == false) {
597 message("Setting up sam.ldb index\n");
598 setup_add_ldif("provision_index.ldif", info, samdb, false);
600 var commit_ok = samdb.transaction_commit();
602 info.message("samdb commit failed: " + samdb.errstring() + "\n");
609 /* Write out a DNS zone file, from the info in the current database */
610 function provision_dns(subobj, message, paths, session_info, credentials)
612 message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n");
613 var ldb = ldb_init();
614 ldb.session_info = session_info;
615 ldb.credentials = credentials;
617 /* connect to the sam */
618 var ok = ldb.connect(paths.samdb);
621 /* These values may have changed, due to an incoming SamSync,
622 or may not have been specified, so fetch them from the database */
624 var attrs = new Array("objectGUID");
625 res = ldb.search("objectGUID=*", subobj.BASEDN, ldb.SCOPE_BASE, attrs);
626 assert(res.length == 1);
627 assert(res[0].objectGUID != undefined);
628 subobj.DOMAINGUID = res[0].objectGUID;
630 subobj.HOSTGUID = searchone(ldb, subobj.BASEDN, "(&(objectClass=computer)(cn=" + subobj.NETBIOSNAME + "))", "objectGUID");
631 assert(subobj.HOSTGUID != undefined);
633 setup_file("provision.zone",
637 message("Please install the zone located in " + paths.dns + " into your DNS server\n");
640 /* Write out a DNS zone file, from the info in the current database */
641 function provision_ldapbase(subobj, message, paths)
643 message("Setting up LDAP base entry: " + subobj.BASEDN + " \n");
644 var rdns = split(",", subobj.BASEDN);
645 subobj.EXTENSIBLEOBJECT = "objectClass: extensibleObject";
647 subobj.RDN_DC = substr(rdns[0], strlen("DC="));
649 setup_file("provision_basedn.ldif",
650 message, paths.ldap_basedn_ldif,
653 message("Please install the LDIF located in " + paths.ldap_basedn_ldif + " into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server\n");
658 guess reasonably default options for provisioning
660 function provision_guess()
662 var subobj = new Object();
663 var nss = nss_init();
664 var lp = loadparm_init();
668 subobj.REALM = strupper(lp.get("realm"));
669 subobj.DOMAIN = lp.get("workgroup");
670 subobj.HOSTNAME = hostname();
672 assert(subobj.REALM);
673 assert(subobj.DOMAIN);
674 assert(subobj.HOSTNAME);
676 subobj.VERSION = version();
677 subobj.HOSTIP = hostip();
678 subobj.DOMAINSID = randsid();
679 subobj.INVOCATIONID = randguid();
680 subobj.KRBTGTPASS = randpass(12);
681 subobj.MACHINEPASS = randpass(12);
682 subobj.ADMINPASS = randpass(12);
683 subobj.DEFAULTSITE = "Default-First-Site-Name";
684 subobj.NEWGUID = randguid;
685 subobj.NTTIME = nttime;
686 subobj.LDAPTIME = ldaptime;
687 subobj.DATESTRING = datestring;
688 subobj.ROOT = findnss(nss.getpwnam, "root");
689 subobj.NOBODY = findnss(nss.getpwnam, "nobody");
690 subobj.NOGROUP = findnss(nss.getgrnam, "nogroup", "nobody");
691 subobj.WHEEL = findnss(nss.getgrnam, "wheel", "root", "staff", "adm");
692 subobj.BACKUP = findnss(nss.getgrnam, "backup", "wheel", "root", "staff");
693 subobj.USERS = findnss(nss.getgrnam, "users", "guest", "other", "unknown", "usr");
694 subobj.DNSDOMAIN = strlower(subobj.REALM);
695 subobj.DNSNAME = sprintf("%s.%s",
696 strlower(subobj.HOSTNAME),
698 rdn_list = split(".", subobj.DNSDOMAIN);
699 subobj.BASEDN = "DC=" + join(",DC=", rdn_list);
700 subobj.LDAPBACKEND = "users.ldb";
701 subobj.LDAPMODULE = "entryUUID";
702 subobj.LDAPMODULES = "objectguid";
703 subobj.EXTENSIBLEOBJECT = "# no objectClass: extensibleObject for local ldb";
704 subobj.ACI = "# no aci for local ldb";
709 search for one attribute as a string
711 function searchone(ldb, basedn, expression, attribute)
713 var attrs = new Array(attribute);
714 res = ldb.search(expression, basedn, ldb.SCOPE_SUBTREE, attrs);
715 if (res.length != 1 ||
716 res[0][attribute] == undefined) {
719 return res[0][attribute];
723 modify an account to remove the
725 function enable_account(ldb, user_dn)
727 var attrs = new Array("userAccountControl");
728 var res = ldb.search(NULL, user_dn, ldb.SCOPE_ONELEVEL, attrs);
729 assert(res.length == 1);
730 var userAccountControl = res[0].userAccountControl;
731 userAccountControl = userAccountControl - 2; /* remove disabled bit */
735 replace: userAccountControl
736 userAccountControl: %u
738 user_dn, userAccountControl);
739 var ok = ldb.modify(mod);
745 add a new user record
747 function newuser(username, unixname, password, message, session_info, credentials)
749 var lp = loadparm_init();
750 var samdb = lp.get("sam database");
751 var ldb = ldb_init();
753 ldb.session_info = session_info;
754 ldb.credentials = credentials;
756 /* connect to the sam */
757 var ok = ldb.connect(samdb);
760 ldb.transaction_start();
762 /* find the DNs for the domain and the domain users group */
763 var attrs = new Array("defaultNamingContext");
764 res = ldb.search("defaultNamingContext=*", "", ldb.SCOPE_BASE, attrs);
765 assert(res.length == 1 && res[0].defaultNamingContext != undefined);
766 var domain_dn = res[0].defaultNamingContext;
767 assert(domain_dn != undefined);
768 var dom_users = searchone(ldb, domain_dn, "name=Domain Users", "dn");
769 assert(dom_users != undefined);
771 var user_dn = sprintf("CN=%s,CN=Users,%s", username, domain_dn);
775 the new user record. note the reliance on the samdb module to fill
786 user_dn, username, dom_users,
789 add the user to the users group as well
791 var modgroup = sprintf("
803 message("Adding user %s\n", user_dn);
806 message("Failed to add %s - %s\n", user_dn, ldb.errstring());
810 message("Modifying group %s\n", dom_users);
811 ok = ldb.modify(modgroup);
813 message("Failed to modify %s - %s\n", dom_users, ldb.errstring());
818 modify the userAccountControl to remove the disabled bit
820 ok = enable_account(ldb, user_dn);
822 ldb.transaction_commit();
827 // Check whether a name is valid as a NetBIOS name.
828 // FIXME: There are probably more constraints here.
829 // crh has a paragraph on this in his book (1.4.1.1)
830 function valid_netbios_name(name)
832 if (strlen(name) > 13) return false;
836 function provision_validate(subobj, message)
838 var lp = loadparm_init();
840 if (!valid_netbios_name(subobj.DOMAIN)) {
841 message("Invalid NetBIOS name for domain\n");
845 if (!valid_netbios_name(subobj.NETBIOSNAME)) {
846 message("Invalid NetBIOS name for host\n");
851 if (strupper(lp.get("workgroup")) != strupper(subobj.DOMAIN)) {
852 message("workgroup '%s' in smb.conf must match chosen domain '%s'\n",
853 lp.get("workgroup"), subobj.DOMAIN);
857 if (strupper(lp.get("realm")) != strupper(subobj.REALM)) {
858 message("realm '%s' in smb.conf must match chosen realm '%s'\n",
859 lp.get("realm"), subobj.REALM);
866 function join_domain(domain, netbios_name, join_type, creds, message)
868 var ctx = NetContext(creds);
869 var joindom = new Object();
870 joindom.domain = domain;
871 joindom.join_type = join_type;
872 joindom.netbios_name = netbios_name;
873 if (!ctx.JoinDomain(joindom)) {
874 message("Domain Join failed: " + joindom.error_string);
880 /* Vampire a remote domain. Session info and credentials are required for for
881 * access to our local database (might be remote ldap)
884 function vampire(domain, session_info, credentials, message) {
885 var ctx = NetContext(credentials);
886 var vampire_ctx = new Object();
887 var machine_creds = credentials_init();
888 machine_creds.set_domain(form.DOMAIN);
889 if (!machine_creds.set_machine_account()) {
890 message("Failed to access domain join information!");
893 vampire_ctx.machine_creds = machine_creds;
894 vampire_ctx.session_info = session_info;
895 if (!ctx.SamSyncLdb(vampire_ctx)) {
896 message("Migration of remote domain to Samba failed: " + vampire_ctx.error_string);