fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone {
  6. static void main(String[] args) {
  7. def canonicalName = "/Example/Exchange/Groups/Roles/Staff/Staff-Role1";
  8. def domain = "DC=" + canonicalName.tokenize("/").reverse()[-1] + ",DC=COM";
  9. def ouDN = "OU=" + canonicalName.tokenize("/").reverse()[1];
  10. def ouName = canonicalName.tokenize("/").reverse()[1];
  11. def path = "OU=" + canonicalName.tokenize("/").reverse()[1..-2].join(",OU=");
  12. System.out.println("Domain Value = " + domain);
  13. System.out.println("OU DN Value = " + ouDN);
  14. System.out.println("OU Name Value = " + ouName);
  15. System.out.println("Full Path Value = " + path);
  16. System.out.println("Complete = " + path + ',' + domain);
  17. }
  18. }
Success #stdin #stdout 1.2s 2252800KB
stdin
Standard input is empty
stdout
Domain Value = DC=Example,DC=COM
OU DN Value = OU=Staff
OU Name Value = Staff
Full Path Value = OU=Staff,OU=Roles,OU=Groups,OU=Exchange
Complete = OU=Staff,OU=Roles,OU=Groups,OU=Exchange,DC=Example,DC=COM