github.com/pmoroney/dnscontrol@v0.2.4-0.20171024134423-fad98f73f44a/providers/activedir/activedirProvider.go (about) 1 package activedir 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "runtime" 7 8 "github.com/StackExchange/dnscontrol/providers" 9 ) 10 11 // This is the struct that matches either (or both) of the Registrar and/or DNSProvider interfaces: 12 type adProvider struct { 13 adServer string 14 fake bool 15 psOut string 16 psLog string 17 } 18 19 var docNotes = providers.DocumentationNotes{ 20 providers.DocDualHost: providers.Cannot("This driver does not manage NS records, so should not be used for dual-host scenarios"), 21 providers.DocCreateDomains: providers.Cannot("AD depends on the zone already existing on the dns server"), 22 providers.DocOfficiallySupported: providers.Can(), 23 providers.CanUseAlias: providers.Cannot(), 24 providers.CanUseSRV: providers.Cannot(), 25 providers.CanUsePTR: providers.Cannot(), 26 providers.CanUseCAA: providers.Cannot(), 27 } 28 29 // Register with the dnscontrol system. 30 // This establishes the name (all caps), and the function to call to initialize it. 31 func init() { 32 providers.RegisterDomainServiceProviderType("ACTIVEDIRECTORY_PS", newDNS, docNotes) 33 } 34 35 func newDNS(config map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) { 36 37 fake := false 38 if fVal := config["fakeps"]; fVal == "true" { 39 fake = true 40 } else if fVal != "" && fVal != "false" { 41 return nil, fmt.Errorf("fakeps value must be 'true' or 'false'") 42 } 43 44 psOut, psLog := config["psout"], config["pslog"] 45 if psOut == "" { 46 psOut = "dns_update_commands.ps1" 47 } 48 if psLog == "" { 49 psLog = "powershell.log" 50 } 51 52 p := &adProvider{psLog: psLog, psOut: psOut, fake: fake} 53 if fake { 54 return p, nil 55 } 56 if runtime.GOOS == "windows" { 57 srv := config["ADServer"] 58 if srv == "" { 59 return nil, fmt.Errorf("ADServer required for Active Directory provider") 60 } 61 p.adServer = srv 62 return p, nil 63 } 64 fmt.Printf("WARNING: PowerShell not available. ActiveDirectory will not be updated.\n") 65 return providers.None{}, nil 66 }