else:
print(f"{err}{klass}: {msg} - {evalue}", file=self.errf)
- def ldb_connect(self, ldap_url, sambaopts, credopts):
+ def ldb_connect(self, hostopts, sambaopts, credopts):
"""Helper to connect to Ldb database using command line opts."""
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
- return SamDB(ldap_url, credentials=creds,
+ return SamDB(hostopts.H, credentials=creds,
session_info=system_session(lp), lp=lp)
def print_json(self, data):
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
# Authentication policies grouped by cn.
try:
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication policy to view (required).",
dest="name", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
policy = AuthenticationPolicy.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
dest="name", action="store", type=str, required=True),
Option("--description",
dest="computer_allowed_to_authenticate_to", type=str, action="store"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
description=None, protect=None, unprotect=None, audit=None,
enforce=None, strong_ntlm_policy=None, user_tgt_lifetime=None,
user_allow_ntlm_auth=None, user_allowed_to_authenticate_from=None,
if audit and enforce:
raise CommandError("--audit and --enforce cannot be used together.")
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
policy = AuthenticationPolicy.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
dest="name", action="store", type=str, required=True),
Option("--description",
dest="computer_allowed_to_authenticate_to", type=str, action="store"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
description=None, protect=None, unprotect=None, audit=None,
enforce=None, strong_ntlm_policy=None, user_tgt_lifetime=None,
user_allow_ntlm_auth=None, user_allowed_to_authenticate_from=None,
if audit and enforce:
raise CommandError("--audit and --enforce cannot be used together.")
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
policy = AuthenticationPolicy.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
dest="name", action="store", type=str, required=True),
Option("--force", help="Force delete protected authentication policy.",
dest="force", action="store_true")
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
force=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
policy = AuthenticationPolicy.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
# Authentication silos grouped by cn.
try:
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo to view (required).",
dest="name", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
Option("--description",
except (LookupError, ValueError) as e:
raise CommandError(e)
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
description=None, policy=None, user_policy=None,
service_policy=None, computer_policy=None, protect=None,
unprotect=None, audit=None, enforce=None):
service_policy = service_policy or policy
computer_policy = computer_policy or policy
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
Option("--description",
except (LookupError, ModelError, ValueError) as e:
raise CommandError(e)
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
description=None, policy=None, user_policy=None,
service_policy=None, computer_policy=None, protect=None,
unprotect=None, audit=None, enforce=None):
service_policy = service_policy or policy
computer_policy = computer_policy or policy
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
Option("--force", help="Force delete protected authentication silo.",
dest="force", action="store_true")
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
force=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
dest="member", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
name=None, member=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
name=None, output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
dest="name", action="store", type=str, required=True),
dest="member", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
name=None, member=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
silo = AuthenticationSilo.get(ldb, cn=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--attribute", help="Attribute of claim type to create (required).",
dest="attribute_name", action="store", type=str, required=True),
Option("--class", help="Object classes to set claim type to.",
dest="unprotect", action="store_true")
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
attribute_name=None, class_names=None, description=None,
disable=None, enable=None, protect=None, unprotect=None):
if protect and unprotect:
raise CommandError("--protect and --unprotect cannot be used together.")
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
display_name = name or attribute_name
try:
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to modify (required).",
dest="name", action="store", type=str, required=True),
Option("--class", help="Object classes to set claim type to.",
dest="unprotect", action="store_true")
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None,
class_names=None, description=None, enable=None, disable=None,
protect=None, unprotect=None):
if protect and unprotect:
raise CommandError("--protect and --unprotect cannot be used together.")
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
claim_type = ClaimType.get(ldb, display_name=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to delete (required).",
dest="name", action="store", type=str, required=True),
Option("--force", help="Force claim type delete even if it is protected.",
dest="force", action="store_true")
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
name=None, force=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
claim_type = ClaimType.get(ldb, display_name=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
# Claim types grouped by displayName.
try:
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to view (required).",
dest="name", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
claim_type = ClaimType.get(ldb, display_name=name)
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
# Value types grouped by display name.
try:
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server.",
- type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Display name of claim value type to view (required).",
dest="name", action="store", type=str, required=True),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
+ def run(self, hostopts=None, sambaopts=None, credopts=None, name=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
value_type = ValueType.get(ldb, display_name=name)
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, hostopts=None, sambaopts=None, credopts=None,
versionopts=None, output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
# sites by cn.
try:
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="ldap_url"),
- ]
-
- def run(self, sitename, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, sitename, hostopts=None, sambaopts=None, credopts=None,
versionopts=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
site = Site.get(ldb, cn=sitename)
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, sitename, H=None, sambaopts=None, credopts=None,
+ def run(self, sitename, hostopts=None, sambaopts=None, credopts=None,
versionopts=None):
- samdb = self.ldb_connect(H, sambaopts, credopts)
+ samdb = self.ldb_connect(hostopts, sambaopts, credopts)
samdb.transaction_start()
try:
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, sitename, H=None, sambaopts=None, credopts=None,
+ def run(self, sitename, hostopts=None, sambaopts=None, credopts=None,
versionopts=None):
- samdb = self.ldb_connect(H, sambaopts, credopts)
+ samdb = self.ldb_connect(hostopts, sambaopts, credopts)
samdb.transaction_start()
try:
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="ldap_url"),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
- def run(self, sitename, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, sitename, hostopts=None, sambaopts=None, credopts=None,
versionopts=None, output_format=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
site = Site.get(ldb, cn=sitename)
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="ldap_url"),
- ]
-
- def run(self, subnetname, ldap_url=None, sambaopts=None, credopts=None,
+ def run(self, subnetname, hostopts=None, sambaopts=None, credopts=None,
versionopts=None):
- ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
+ ldb = self.ldb_connect(hostopts, sambaopts, credopts)
try:
subnet = Subnet.get(ldb, cn=subnetname)
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, subnetname, site_of_subnet, H=None, sambaopts=None,
+ def run(self, subnetname, site_of_subnet, hostopts=None, sambaopts=None,
credopts=None, versionopts=None):
- samdb = self.ldb_connect(H, sambaopts, credopts)
+ samdb = self.ldb_connect(hostopts, sambaopts, credopts)
samdb.transaction_start()
try:
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, subnetname, H=None, sambaopts=None, credopts=None,
+ def run(self, subnetname, hostopts=None, sambaopts=None, credopts=None,
versionopts=None):
- samdb = self.ldb_connect(H, sambaopts, credopts)
+ samdb = self.ldb_connect(hostopts, sambaopts, credopts)
samdb.transaction_start()
try:
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
+ "hostopts": options.HostOptions,
}
- takes_options = [
- Option("-H", "--URL", help="LDB URL for database or target server",
- type=str, metavar="URL", dest="H"),
- ]
-
- def run(self, subnetname, site_of_subnet, H=None, sambaopts=None,
+ def run(self, subnetname, site_of_subnet, hostopts=None, sambaopts=None,
credopts=None, versionopts=None):
- samdb = self.ldb_connect(H, sambaopts, credopts)
+ samdb = self.ldb_connect(hostopts, sambaopts, credopts)
samdb.transaction_start()
try: