Tuesday, February 12, 2013

How to return custom error messages in ECMA2 SP1

While updating my Management Agents (or connectors) and building a new one for a customer, I wanted to take advantage of the new possibility in the Service Pack 1 version of the ECMA2 framework where you can return a custom errorname and error detail to the Synchronization Service Manager. It took me sometime to get my head around this, but I finally got it working.

Before Service Pack 1, you could also use the CSEntryChangeResult to return a error on your imports and export actions. In your PutExportEntries interface code, you would put something like this to return a export error -

CSEntryChangeResult cschangeresult = CSEntryChangeResult.Create(csentryChange.Identifier, null, MAExportError.ExportErrorSyntaxViolation);

This line above would show up as a export error with the error code 'syntax-violation' in the Synchronization Service Manager. You can find the additional MAExportError options here (http://msdn.microsoft.com/en-us/library/microsoft.metadirectoryservices.maexporterror(v=vs.100).aspx).

With Service Pack 1, however, you are now able to return a custom error name and detail, which is awesome because you can give more information to the administrator. The caveat is that you do need to set MAExportError to either ExportErrorCustomContinueRun or ExportErrorCustomStopRun for your custom error information to be returned. These two enumeration options are new for Service Pack 1 and I was struggling for a few hours before I noticed these.

So after changing my MAExportError enumeration value to ExportErrorCustomContinueRun, my custom error message was returned to the Synchronization Service Manager. My line now looks like this -

CSEntryChangeResult cschangeresult = CSEntryChangeResult.Create(csentryChange.Identifier, null, MAExportError.ExportErrorCustomContinueRun, "script-error", scriptResult);

Notice that I keep my error name to the general, well-known syntax of <warning/error>-<message> (second last parameter). I just like this as a best practise but it is not a requirement; you can write any text, you like.

Happy coding.


Jason Bell said...

Perfect! I have been trying to figure this out out also. Sometimes the most difficult problem to solve is the one that is easiest to see.

Kayal said...

I like this blog, this is a very simple but very good explanation about this useful topic. Well done and keep continuing...
Oracle Training in Chennai
Oracle Training institute in chennai
Social Media Marketing Courses in Chennai
Tableau Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Oracle Training in Chennai
Oracle Training institute in chennai

Reshma said...

Nice blog! Thanks for sharing this valuable information
Software Testing Training in Chennai
Software Testing Training in Bangalore
Software Testing Course in Coimbatore
Software Testing Training in Madurai
Software Testing Training Institute in Bangalore
Software Testing Course in Bangalore
Testing Course in Bangalore
Ethical hacking course in bangalore

thagukavi said...

Amazing Post. keep update more information.
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
IELTS Online Coaching
IELTS Coaching in Coimbatore
IELTS coaching in Madurai

hema said...

Thank you for the useful blog. It's very interesting. Share more updates.
English Grammar
First conditional

Saba said...

Searching for a career in cybersecurity? Look no further than Indian Cyber Security Solutions for Certified Ethical Hacking Training. Our training programme is created to provide you the theoretical understanding, hands-on expertise, and certification necessary to be successful in this highly demanded industry.

Our training is meticulously crafted and taught by seasoned experts with a wealth of experience. You'll learn the latest techniques, tools, and methodologies used by professional ethical hackers while gaining hands-on experience through real-world scenarios. Sharpen your problem-solving abilities and unleash your potential as a certified ethical hacker.

Join us today to embark on a transformative journey towards an exciting career in cybersecurity!

Rush kya said...

When it comes to the best Certified Ethical Hacker (CEH) training in Kolkata, ICSS (Indian Cyber Security Solutions) stands out as a top choice. ICSS is renowned for its comprehensive and practical approach to cybersecurity education.

ICSS offers a highly specialized CEH training program that covers the latest techniques and tools used by ethical hackers to identify vulnerabilities in systems and networks. The training is conducted by experienced industry professionals who have hands-on expertise in the field of cybersecurity. They provide real-world scenarios, case studies, and practical exercises to ensure that students gain practical skills and knowledge.

ICSS's CEH training curriculum aligns with industry standards and covers a wide range of topics, including foot printing and reconnaissance, system hacking, network scanning, web application penetration testing, wireless network security, and more. The training also focuses on the legal and ethical aspects of ethical hacking.

Additionally, ICSS offers a conducive learning environment with well-equipped labs and resources. They provide ongoing support and guidance to their students even after the completion of the training, helping them build successful careers in cybersecurity.

In summary, ICSS in Kolkata is considered the best choice for CEH training due to its practical approach, experienced instructors, comprehensive curriculum, and commitment to producing skilled ethical hackers.

Saba said...

Indian Cyber Security Solutions Institute invites you to our Ethical Hacking training course in Bangalore. Discover the art of ethical hacking and learn how to secure networks, systems, and applications from malicious attacks.

Siem Xpert said...

Nice informative post . Thanks for sharing . To explore more about Cyber Security Training learn from industry experts.

Saba said...

Unlock the secrets of ethical hacking with Indian Cyber Security Solutions' specialized Ethical hacking Training in Kolkata! Our hands-on approach allows you to learn through real-world scenarios, preparing you to tackle cyber threats head-on and become a valuable asset to any organization.