Expand|Select|Wrap|Line Numbers
- public void DeleteRecord(string domain, string recordName, string recordType, string recordData)
- {
- try
- {
- this.ConnectToDNS(dnsServerList[x].Server, dnsServerList [x].UserName, dnsServerList[x].Pass);
- // Find Record to Delete
- string wql = "";
- wql = "SELECT *";
- wql += " FROM MicrosoftDNS_TXTType";
- wql += " WHERE ContainerName = '" + domain + "'";
- wql += " AND recordData = '" + recordData + "'";
- wql += " AND OwnerName = '" + ownerName + "'";
- ObjectQuery q = new ObjectQuery(wql);
- ManagementObjectSearcher s = new ManagementObjectSearcher(this.Session, q);
- ManagementObjectCollection col = s.Get();
- int total = col.Count;
- foreach (ManagementObject o in col)
- {
- // Record to Delete was found
- o.Delete();
- o.Dispose();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
Here is a TXT record created manually on the Dns Server:
" TXT ( "v=spf1 ip4:0.0.0.0 ip4:0.0.0.0 ?all" )"
Here is a TXT record created by C# code:
" TXT ( "v=spf1 ip4:0.0.0.0 ip4:0.0.0.0 ?all"
"" )"
The interesting thing is, if I edit the TXT record manually on the Dns Server and move the cursor to the end of the text in the TextBox and hit the 'Enter' key on my keyboard then save the change, my C# code can then delete that TXT record. When you type 'Enter' after the text in the textbox on a Dns Server it formats the record to match my C# code.
Anyway I just need to find out why I can't delete a TXT record that was manually created on a Dns Server when the person entering the text does not actually hit the 'Enter' key. I would appreciate any help you could provide. Thanks in adavance.