If you are using Spring Framework, you may use DistinguishedName as follow:
String path = "CN=Jimmy Blooptoop,OU=Someplace,OU=Employees,DC=Bloopsoft-Inc";
DistinguishedName dn = new DistinguishedName(path);
String cn = dn.getValue("cn"); // Jimmy Blooptoop