groovydn

construct DN with groovy


I need to replace below code value with location value .

string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 
DN = str.replaceAll( "Code" , LOCATION ) ;

I am getting incorrect signature of the method as string definition consist "=" and "," symbols . any help ?

Thanks.


Solution

  • No need go setting up the wrong string then use replace to make it right.

    Just use templating to create the correct string. Ie:

    String DN = "OU=Contractors,OU=Users,OU=$LOCATION,OU=Sites,DC=xyz,DC=com"