MsDNS2012 fix
This commit is contained in:
parent
61f6820f98
commit
1fee4f0f85
2 changed files with 52 additions and 8 deletions
|
@ -306,17 +306,61 @@ namespace WebsitePanel.Providers.DNS
|
|||
ps.RunPipeline( cmd );
|
||||
}
|
||||
|
||||
public static void Remove_DnsServerResourceRecord( this PowerShellHelper ps, string zoneName, string Name, string type, string recordData )
|
||||
public static void Remove_DnsServerResourceRecord( this PowerShellHelper ps, string zoneName, DnsRecord record)
|
||||
{
|
||||
string type;
|
||||
if (!RecordTypes.rrTypeFromRecord.TryGetValue(record.RecordType, out type))
|
||||
throw new Exception( "Unknown record type" );
|
||||
|
||||
string Name = record.RecordName;
|
||||
if (String.IsNullOrEmpty(Name)) Name = "@";
|
||||
|
||||
var cmd = new Command( "Remove-DnsServerResourceRecord" );
|
||||
var cmd = new Command("Get-DnsServerResourceRecord");
|
||||
cmd.addParam("ZoneName", zoneName);
|
||||
cmd.addParam("Name", Name);
|
||||
cmd.addParam("RRType", type);
|
||||
Collection<PSObject> resourceRecords = ps.RunPipeline(cmd);
|
||||
|
||||
if (!String.IsNullOrEmpty(recordData))
|
||||
cmd.addParam("RecordData", recordData);
|
||||
object inputObject = null;
|
||||
foreach (PSObject resourceRecord in resourceRecords)
|
||||
{
|
||||
DnsRecord dnsResourceRecord = resourceRecord.asDnsRecord(zoneName);
|
||||
|
||||
bool found = false;
|
||||
|
||||
switch(dnsResourceRecord.RecordType)
|
||||
{
|
||||
case DnsRecordType.A:
|
||||
case DnsRecordType.AAAA:
|
||||
case DnsRecordType.CNAME:
|
||||
case DnsRecordType.NS:
|
||||
case DnsRecordType.TXT:
|
||||
found = dnsResourceRecord.RecordData == record.RecordData;
|
||||
break;
|
||||
case DnsRecordType.SOA:
|
||||
found = true;
|
||||
break;
|
||||
case DnsRecordType.MX:
|
||||
found = (dnsResourceRecord.RecordData == record.RecordData) && (dnsResourceRecord.MxPriority == record.MxPriority);
|
||||
break;
|
||||
case DnsRecordType.SRV:
|
||||
found = (dnsResourceRecord.RecordData == record.RecordData)
|
||||
&&(dnsResourceRecord.SrvPriority == record.SrvPriority)
|
||||
&&(dnsResourceRecord.SrvWeight == record.SrvWeight)
|
||||
&&(dnsResourceRecord.SrvPort == record.SrvPort);
|
||||
break;
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
inputObject = resourceRecord;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cmd = new Command( "Remove-DnsServerResourceRecord" );
|
||||
cmd.addParam( "ZoneName", zoneName );
|
||||
cmd.addParam("InputObject", inputObject);
|
||||
|
||||
cmd.addParam( "Force" );
|
||||
ps.RunPipeline( cmd );
|
||||
|
|
|
@ -172,7 +172,7 @@ namespace WebsitePanel.Providers.DNS
|
|||
string rrType;
|
||||
if( !RecordTypes.rrTypeFromRecord.TryGetValue( record.RecordType, out rrType ) )
|
||||
throw new Exception( "Unknown record type" );
|
||||
ps.Remove_DnsServerResourceRecord( zoneName, record.RecordName, rrType, record.RecordData );
|
||||
ps.Remove_DnsServerResourceRecord( zoneName, record);
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue