I am working on configuring Active Directory via Groovy.

      I was able to authenticate via active directory via the UI.

      I have the following based on the LDAP plugin:

          import jenkins.model.*
          import hudson.security.*
          import hudson.plugins.*
          import hudson.plugins.active_directory.*
          import hudson.*
          import jenkins.*
      
          String domain = 'my.domain.com'
          String site = ''
          String server = '192.168.1.1'
          String bindName = 'account@my.domain.com'
          String bindPassword = 'password'
      
          SecurityRealm ad_realm = new ActiveDirectorySecurityRealm(domain, site, bindName, bindPassword, server)
          jenkins.instance.setSecurityRealm(ad_realm)
      

      This is the error:

      Expected process to exit with [0], but received '255'
                 ---- Begin output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                 STDOUT: 
                 STDERR: groovy.lang.MissingPropertyException: No such property: jenkins for class: RemoteClass
                 	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
                 	at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
                 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
                 	at RemoteClass.run(RemoteClass:16)
                 	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)
                 	at groovy.lang.GroovyShell.run(GroovyShell.java:517)
                 	at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
                 	at hudson.cli.CLICommand.main(CLICommand.java:237)
                 	at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92)
                 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                 	at java.lang.reflect.Method.invoke(Method.java:497)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:608)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:583)
                 	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:542)
                 	at hudson.remoting.UserRequest.perform(UserRequest.java:120)
                 	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
                 	at hudson.remoting.Request$2.run(Request.java:326)
                 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
                 	at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63)
                 	at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
                 	at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
                 	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
                 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                 	at java.lang.Thread.run(Thread.java:745)
                 ---- End output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                 Ran "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 returned 255
      

      Any idea on why I see No such property: jenkins for class: RemoteClass?

          [JENKINS-32710] Configure AD Authorization with Groovy

          John Mickey created issue -
          John Mickey made changes -
          Summary Original: Configure AD via Groovy New: Configure AD Authorization with Groovy
          John Mickey made changes -
          Description Original: I am working on configuring Active Directory via Groovy.

          I was able to authenticate via active directory via the UI.

          I have the following based on the LDAP plugin:

          {code:java}
              import jenkins.model.*
              import hudson.security.*
              import hudson.plugins.*

              String domain = 'my.domain.com'
              String server = '192.168.1.1'
              String bindName = 'account@my.domain.com'
              String bindPassword = 'password'

              SecurityRealm ad_realm = new ActiveDirectorySecurityRealm(domain, server, bindName, bindPassword)
              jenkins.instance.setSecurityRealm(ad_realm)
          {code}

          This is the error:

          {noformat}
          STDERR: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
                     RemoteClass: 10: unable to resolve class ActiveDirectorySecurityRealm
                      @ line 10, column 26.
                 SecurityRealm ad_realm = new ActiveDirectorySecurityRealm(domain, server, bindName, bindPassword)
                                          ^
                     
                     1 error
                     
                      at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
                      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:861)
                      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:550)
                      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:499)
                      at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:302)
                      at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281)
                      at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
                      at groovy.lang.GroovyShell.run(GroovyShell.java:516)
                      at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
                      at hudson.cli.CLICommand.main(CLICommand.java:237)
                      at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                      at java.lang.reflect.Method.invoke(Method.java:497)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:608)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:583)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:542)
                      at hudson.remoting.UserRequest.perform(UserRequest.java:120)
                      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
                      at hudson.remoting.Request$2.run(Request.java:326)
                      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
                      at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63)
                      at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
                      at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
                      at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                      at java.lang.Thread.run(Thread.java:745)
          {noformat}

          How do I call the class? Am I on the right track? Any help is appreciated. I will post a working configuration before resolving the ticket.
          New: I am working on configuring Active Directory via Groovy.

          I was able to authenticate via active directory via the UI.

          I have the following based on the LDAP plugin:

          {code:java}
              import jenkins.model.*
              import hudson.security.*
              import hudson.plugins.*
              import hudson.plugins.active_directory.*
              import hudson.*
              import jenkins.*

              String domain = 'my.domain.com'
              String site = ''
              String server = '192.168.1.1'
              String bindName = 'account@my.domain.com'
              String bindPassword = 'password'

              SecurityRealm ad_realm = new ActiveDirectorySecurityRealm(domain, site, bindName, bindPassword, server)
              jenkins.instance.setSecurityRealm(ad_realm)
          {code}

          This is the error:

          {noformat}
          Expected process to exit with [0], but received '255'
                     ---- Begin output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                     STDOUT:
                     STDERR: groovy.lang.MissingPropertyException: No such property: jenkins for class: RemoteClass
                      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
                      at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
                      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
                      at RemoteClass.run(RemoteClass:16)
                      at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)
                      at groovy.lang.GroovyShell.run(GroovyShell.java:517)
                      at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
                      at hudson.cli.CLICommand.main(CLICommand.java:237)
                      at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                      at java.lang.reflect.Method.invoke(Method.java:497)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:608)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:583)
                      at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:542)
                      at hudson.remoting.UserRequest.perform(UserRequest.java:120)
                      at hudson.remoting.UserRequest.perform(UserRequest.java:48)
                      at hudson.remoting.Request$2.run(Request.java:326)
                      at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
                      at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63)
                      at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
                      at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
                      at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                      at java.lang.Thread.run(Thread.java:745)
                     ---- End output of "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 ----
                     Ran "/opt/java/latest/bin/java" -jar "/tmp/kitchen/cache/jenkins-cli.jar" -s http://localhost:8080 groovy /tmp/groovy20160208-28479-azdr83 returned 255
          {noformat}

          Any idea on why I see No such property: jenkins for class: RemoteClass?
          John Mickey made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          John Mickey made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 168372 ] New: JNJira + In-Review [ 209661 ]
          Vishwadeep Bansal made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]
          Konstantinos Psimoulis made changes -
          Link New: This issue is related to JENKINS-48513 [ JENKINS-48513 ]
          Konstantinos Psimoulis made changes -
          Link New: This issue is related to JENKINS-44822 [ JENKINS-44822 ]

            Unassigned Unassigned
            jsmickey John Mickey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: