Skip to content
Richard Pearson edited this page Oct 9, 2013 · 7 revisions

How To

- How to connect to the registry?

var tcpTransport = new TcpTransport("epp.registry", 700, new X509Certificate("mycert.pfx", "p4ssw0rd"), true);

var service = new Service(tcpTransport);

// SSL connection establishment
service.Connect();

- How to login?

var logingCmd = new Login("username", "password");
logingCmd.Options = new Options {MLang = "en", MVersion = "1.0"};

var services = new Services();

services.ObjURIs.Add("urn:ietf:params:xml:ns:epp-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:domain-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:host-1.0");
services.ObjURIs.Add("urn:ietf:params:xml:ns:contact-1.0");

//CIRA extensions
services.Extensions.Add("urn:ietf:params:xml:ns:cira-1.0");
services.Extensions.Add("urn:ietf:params:xml:ns:poll-1.0");

logingCmd.Services = services;

var response = service.Execute(logingCmd);

if(!response.Code.Equals("1000"))
{
	throw new ApplicationException("Authentication failed");
}

- How to get the CIRA registrar agreement?

var agreementCmd = new GetAgreement();

var getAgreementResponse = service.Execute(agreementCmd);

var agreementVersion = getAgreementResponse.AgreementVersion;
var agreementText = getAgreementResponse.Agreement;
var agreementLanguage = getAgreementResponse.Language;

- How to create a contact?

var registrantContact = new Contact("xxxx",
	"Registrant Full Name", "Example Inc.",
	"Toronto", "Address", "ON", "M5V3T1", "CA",
	"[email protected]",
	new Telephone { Value = "+1.6471114444", Extension = "333" },
	new Telephone { Value = "+1.6471114445" });

var registrantContactCmd = new ContactCreate(registrantContact);

var ciraExtension = new CiraCreateExtension
{
	Language = "en",
	OriginatingIpAddress = "127.0.0.1",
	CprCategory = CprCategory.CCT,
	AgreementVersion = "2.0",
	AggreementValue = "Y",
	CreatedByResellerId = "resellerId"
};

registrantContactCmd.Extensions.Add(ciraExtension);

response = service.Execute(registrantContactCmd);

- How to change a domain’s contact?

var registrantTransferCmd = new DomainUpdate("mydomain.ca");

registrantTransferCmd.DomainChange = new DomainChange { RegistrantContactId = "newcontactid" };

response = service.Execute(registrantTransferCmd);

- How to update a contact’s information?

var contactUpdateCmd = new ContactUpdate(registrantContact.Id);

var contactChange = new ContactChange(registrantContact);

contactChange.Fax = new Telephone("2223334444", "123");

contactUpdateCmd.ContactChange = contactChange;

// CIRA CPR extension
contactUpdateCmd.Extensions.Add(new CiraContactUpdateExtension { CprCategory = CiraCprCategories.CCT });

response = service.Execute(contactUpdateCmd);

- How to check if a domain is available for registration?

var domainCheckCmd = new DomainCheck("mydomain.ca");

response = service.Execute(domainCheckCmd) as DomainCheckResponse;

if(response.Results[0].Available){
	// add to shopping cart
}

- How to register a domain?

var domainCreateCmd = new DomainCreate("mydomain.ca", "contactid");

domainCreateCmd.DomainContacts.Add(new DomainContact("admincontactid", "admin"));

//NOTE: password is compulsory
domainCreateCmd.Password = "s0mer4ndom";

response = service.Execute(domainCreateCmd);

- How to check if a host exists?

var hostCheckCmd = new HostCheck(new List { "ns1.example.com", "ns2.example.com" });

response = service.Execute(hostCheckCmd);

- How to create a host or nameserver?

var host = new Host("ns1.example.com");
host.Addresses.Add(new HostAddress("127.0.0.1", "v4"));
var hostCreateCmd = new HostCreate(host);

response = service.Execute(hostCreateCmd);

- How to obtain information on a host?

var hostInfoCmd = new HostInfo("ns1.example.com");

response = service.Execute(hostInfoCmd);

- How to update a domain?

var domainUpdateCmd = new DomainUpdate("example.ca");

//NOTE: Nameservers need different IP addresses
domainUpdateCmd.ToAdd.NameServers = new List<string> { "ns1.example.com", "ns2.example.com" };

response = service.Execute(domainUpdateCmd);

- How to update a host?

var hostUpdateCmd = new HostUpdate("ns1.example.com");

var eppHostUpdateAddRemove = new EppHostUpdateAddRemove();

eppHostUpdateAddRemove.Adresses = new List { new HostAddress("1080:0:0:0:8:800:2004:17A", "v6") };
eppHostUpdateAddRemove.Status = new List { new Status("", "clientUpdateProhibited") };

hostUpdateCmd.ToAdd = eppHostUpdateAddRemove;

response = service.Execute(hostUpdateCmd);

- How to obtain information on a domain?

var domainInfoCmd = new DomainInfo("example.ca");
var domainInfo = (DomainInfoResponse)service.Execute(domainInfoCmd);

- How to renew a domain?

var renewCmd = new DomainRenew(domainInfo.Domain.Name, domainInfo.Domain.ExDate, new DomainPeriod(2, "y"));

response = service.Execute(renewCmd);

- How to do a registrar transfer?

var transferCmd = new DomainTransfer("example.ca", null, null, new List());

transferCmd.Password = "p4ssw0rd";
response = service.Execute(transferCmd);

- How to delete a domain?

var deleteDomainCmd = new DomainDelete("example.ca");

response = service.Execute(deleteDomainCmd);

- How to acknowledge and poll messages?

var thereAreMessages = true;

while (thereAreMessages)
{
	var poll = new Poll { Type = PollType.Request };

	var pollResponse = (PollResponse)service.Execute(poll);

    
	if (!String.IsNullOrEmpty(pollResponse.Id))
	{
		//acknowledge
		poll = new Poll { Type = PollType.Acknowledge, MessageId = pollResponse.Id };

		pollResponse = (PollResponse)service.Execute(poll);

		PrintResponse(pollResponse);
	}

	Console.WriteLine("Messages left in the queue:" + pollResponse.Count);

	thereAreMessages = pollResponse.Count != 0;
}

(c) 2011 Code Maker Inc. All rights reserved