【问题标题】:construct DN with groovy用 groovy 构建 DN
【发布时间】:2016-05-12 02:05:39
【问题描述】:

我需要用位置值替换下面的代码值。

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

我得到的方法签名不正确,因为字符串定义包含 "=" 和 "," 符号。有什么帮助吗?

谢谢。

【问题讨论】:

  • 一个字符串可以包含 = 和 , .. 那是不是的问题。请用确切的错误编辑您的问题。我给出了一个推测性的答案。

标签: groovy dn


【解决方案1】:

无需设置错误的字符串,然后使用替换来使其正确。

只需使用模板创建正确的字符串。即:

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

【讨论】:

    【解决方案2】:
    string str = "OU=Contractors,OU=Users,OU=Code,OU=Sites,DC=xyz,DC=com" ; 
    

    看起来不对。 “字符串”不是一个类。它必须是 Stringdef。如下所示

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-18
      • 1970-01-01
      • 2012-02-03
      • 1970-01-01
      相关资源
      最近更新 更多