Nag
Nag

Reputation: 21

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.

Upvotes: -1

Views: 44

Answers (2)

tim_yates
tim_yates

Reputation: 171144

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"

Upvotes: 0

Jayan
Jayan

Reputation: 18458

string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 

Looks wrong. "string" is not a class. It must be String or def. Like below

 String str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 

or

 def str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 

Upvotes: 1

Related Questions