Univention Bugzilla – Attachment 7232 Details for
Bug 39574
Register ucs-sso in AD LDAP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
ipv6.patch
ipv6.patch (text/plain), 3.72 KB, created by
Arvid Requate
on 2015-10-28 20:07 CET
(
hide
)
Description:
ipv6.patch
Filename:
MIME Type:
Creator:
Arvid Requate
Created:
2015-10-28 20:07 CET
Size:
3.72 KB
patch
obsolete
>Index: python/admember.py >=================================================================== >--- python/admember.py (Revision 64949) >+++ python/admember.py (Arbeitskopie) >@@ -1095,7 +1095,7 @@ > ud.debug(ud.MODULE, ud.ERROR, "26univention-samba.inst failed with %d" % (p1.returncode,)) > raise sambaJoinScriptFailed() > >-def add_host_record_in_ad(uid=None, binddn=None, bindpw=None, bindpwdfile=None, fqdn=None, ip=None, sso=False): >+def add_host_record_in_ad(uid=None, binddn=None, bindpw=None, bindpwdfile=None, fqdn=None, ipv4=None, ipv6=None, sso=False): > > pwdfile = None > create_pwdfile = False >@@ -1115,14 +1115,16 @@ > pwdfile = bindpw > > # take myself as default >- if not ip: >- ip = Interfaces().get_default_ip_address().ip >+ if not ipv4: >+ ipv4 = Interfaces().get_default_ipv4_address().ip >+ if not ipv6: >+ ipv6 = Interfaces().get_default_ipv6_address().ip > > if sso and not fqdn: > fqdn = ucr.get('ucs/server/sso/fqdn', 'ucs-sso.' + domainname) > >- if not uid or not pwdfile or not fqdn or not ip: >- print 'Missing binddn/bindpw/bindpwdfile/fqdn or ip, do nothing!' >+ if not (uid and pwdfile and fqdn and (ipv4 or ipv6)): >+ print 'Missing binddn/bindpw/bindpwdfile/fqdn or ipv4/ipv6, do nothing!' > return False > > ad_domain_info = lookup_adds_dc() >@@ -1129,30 +1131,56 @@ > ad_ip = ad_domain_info['DC IP'] > found = False > >- print "Create %s (%s) A record on %s" % (fqdn, ip, ad_ip) >+ resolver = dns.resolver.Resolver() >+ resolver.lifetime = 10 >+ resolver.nameservers = [ad_ip] > >- # check if we are already defined as host record >- try: >- resolver = dns.resolver.Resolver() >- resolver.lifetime = 10 >- resolver.nameservers = [ad_ip] >- response = resolver.query(fqdn, 'A') >- for data in response: >- if str(data) == str(ip): >- found = True >- except dns.resolver.NXDOMAIN: >- found = False >- except Exception as err: >- print 'failed to query for A record (%s, %s)' % (err.__class__.__name__, err.message) >- found = False >- if found: >- print '%s A record for %s found' % (fqdn, ip) >+ if ipv4: >+ print "Create %s (%s) A record on %s" % (fqdn, ipv4, ad_ip) >+ >+ # check if we are already defined as host record >+ try: >+ response = resolver.query(fqdn, 'A') >+ for data in response: >+ if str(data) == str(ipv4): >+ found = True >+ except dns.resolver.NXDOMAIN: >+ found = False >+ except Exception as err: >+ print 'failed to query for A record (%s, %s)' % (err.__class__.__name__, err.message) >+ found = False >+ if found: >+ print '%s A record for %s found' % (fqdn, ipv4) >+ ipv4 = None >+ >+ if ipv6: >+ print "Create %s (%s) AAA record on %s" % (fqdn, ipv6, ad_ip) >+ >+ # check if we are already defined as host record >+ try: >+ response = resolver.query(fqdn, 'AAA') >+ for data in response: >+ if str(data) == str(ipv6): >+ found = True >+ except dns.resolver.NXDOMAIN: >+ found = False >+ except Exception as err: >+ print 'failed to query for AAA record (%s, %s)' % (err.__class__.__name__, err.message) >+ found = False >+ if found: >+ print '%s AAA record for %s found' % (fqdn, ipv6) >+ ipv6 = None >+ >+ if not (ipv4 or ipv6): > return True > > # create host record > fd = tempfile.NamedTemporaryFile(delete=False) > fd.write('server %s\n' % ad_ip) >- fd.write('update add %s 86400 A %s\n' % (fqdn, ip)) >+ if ipv4: >+ fd.write('update add %s 86400 A %s\n' % (fqdn, ipv4)) >+ if ipv6: >+ fd.write('update add %s 86400 AAA %s\n' % (fqdn, ipv6)) > fd.write('send\n') > fd.write('quit\n') > fd.close() >@@ -1172,7 +1200,7 @@ > ud.debug(ud.MODULE, ud.PROCESS, '%s' % stdout) > if p1.returncode: > print '%s failed with %d (%s)' % (cmd, p1.returncode, stderr) >- print 'failed to add A record for ucs-sso to %s' % ad_ip >+ print 'failed to add DNS record for ucs-sso to %s' % ad_ip > return False > finally: > os.unlink(fd.name)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 39574
: 7232