Programmatically create users (application server)
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
I am trying to programmatically create new application server users in RTC. Currently, a user can log into the url https://localhost:9443/jazz and Click User Management and add users by hand. I need to create hundreds of users which is cumbersome. I am playing with the RTC server to see if I can programmatically create new users.
As a start, any http server accepts either GET or POST messages. It is possible to use java.net technique, to open a connection (URLConnection) with the http server and manipulate the server to serve the request. I have had success with many commercial websites.
In context of RTC E,g. When I create a user by hand a url like this is autogenerated in the JavaScript and POST message is sent, so the server can process the request.
https://9.34.120.71:9443/jazz/service/com.ibm.team.repository.service.internal.IAdminRestService/contributor?emailAddress=st3&itemId=new&jsonLicenses=%7B%22add%22%3A%20%5B%22com.ibm.team.rtc.developer%22%5D%2C%20%22remove%22%3A%20%5B%5D%7D&jsonRoles=%5B%22JazzAdmins%22%2C%20%22JazzUsers%22%5D&name=st3&userId=st3
I wrote a plain java client to handle this via SSL (IBM JSSE Provider com.ibm.jsse) since now https:// is being provided with RTC. I created a client keystore file from the server keystore file and imported server keys/certificates. I am not getting any errors, but neither am I seeing any results. Nothing particular in the tomcat logs. I can post the code on request. I was looking if this is the way to go. Any alternative ideas..? Thanks for your time.
As a start, any http server accepts either GET or POST messages. It is possible to use java.net technique, to open a connection (URLConnection) with the http server and manipulate the server to serve the request. I have had success with many commercial websites.
In context of RTC E,g. When I create a user by hand a url like this is autogenerated in the JavaScript and POST message is sent, so the server can process the request.
https://9.34.120.71:9443/jazz/service/com.ibm.team.repository.service.internal.IAdminRestService/contributor?emailAddress=st3&itemId=new&jsonLicenses=%7B%22add%22%3A%20%5B%22com.ibm.team.rtc.developer%22%5D%2C%20%22remove%22%3A%20%5B%5D%7D&jsonRoles=%5B%22JazzAdmins%22%2C%20%22JazzUsers%22%5D&name=st3&userId=st3
I wrote a plain java client to handle this via SSL (IBM JSSE Provider com.ibm.jsse) since now https:// is being provided with RTC. I created a client keystore file from the server keystore file and imported server keys/certificates. I am not getting any errors, but neither am I seeing any results. Nothing particular in the tomcat logs. I can post the code on request. I was looking if this is the way to go. Any alternative ideas..? Thanks for your time.
23 answers
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
Creating a user with the the IContributorManager only creates the users
data in the Jazz DB. To log in wit the user, the username / password
has to be configured in the External User Registry (which could be LDAP,
Tomcat, or unknown/unsupported).
If your user registry is Tomcat then you can add your new user to the
registry with IExternalUserRegistryManager. You can check to see if the
user registry if writeable with isExternalRegistryWriteable(). If it is
writable then you should be able to create a new users entry for your
new user. If your server is configured with LDAP then you would need to
modify the LDAP registry to allow logging in with the new users.
Matt Lavin
Jazz Server Team
warade wrote:
data in the Jazz DB. To log in wit the user, the username / password
has to be configured in the External User Registry (which could be LDAP,
Tomcat, or unknown/unsupported).
If your user registry is Tomcat then you can add your new user to the
registry with IExternalUserRegistryManager. You can check to see if the
user registry if writeable with isExternalRegistryWriteable(). If it is
writable then you should be able to create a new users entry for your
new user. If your server is configured with LDAP then you would need to
modify the LDAP registry to allow logging in with the new users.
Matt Lavin
Jazz Server Team
warade wrote:
After getworkingcopy() a user is created but it cannot log in.
When I log in as ADMIN, and navigate to User Management page and click
the newly created user to see details, I get this message.
This user is not in the directory service. The
user will not be able to login unless they an account in the
directory service.
What is this directory service? How to access it from the client API?
Thanks again.
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
Is your server configured for FORM or BASIC auth? Can you attach the
result that is sent back from the server when you attempt the request?
An alternate approach is to build a small RCP application that re-uses
the RTC client libraries. Taking that approach will enable you to reuse
the same login / service execution code that RTC uses and should save
you a significant amount of reverse-engineering time.
Matt Lavin
Jazz Server Team
warade wrote:
result that is sent back from the server when you attempt the request?
An alternate approach is to build a small RCP application that re-uses
the RTC client libraries. Taking that approach will enable you to reuse
the same login / service execution code that RTC uses and should save
you a significant amount of reverse-engineering time.
Matt Lavin
Jazz Server Team
warade wrote:
I am trying to programmatically create new application server users in
RTC. Currently, a user can log into the url
https://localhost:9443/jazz and Click User Management and add users
by hand. I need to create hundreds of users which is cumbersome. I am
playing with the RTC server to see if I can programmatically create
new users.
As a start, any http server accepts either GET or POST messages. It is
possible to use java.net technique, to open a connection
(URLConnection) with the http server and manipulate the server to
serve the request. I have had success with many commercial websites.
In context of RTC E,g. When I create a user by hand a url like this is
autogenerated in the JavaScript and POST message is sent, so the
server can process the request.
https://9.34.120.71:9443/jazz/service/com.ibm.team.repository.service.internal.IAdminRestService/contributor?emailAddress=st3&itemId=new&jsonLicenses=%7B%22add%22%3A%20%5B%22com.ibm.team.rtc.developer%22%5D%2C%20%22remove%22%3A%20%5B%5D%7D&jsonRoles=%5B%22JazzAdmins%22%2C%20%22JazzUsers%22%5D&name=st3&userId=st3
I wrote a plain java client to handle this via SSL (IBM JSSE Provider
com.ibm.jsse) since now https:// is being provided with RTC. I
created a client keystore file from the server keystore file and
imported server keys/certificates. I am not getting any errors, but
neither am I seeing any results. Nothing particular in the tomcat
logs. I can post the code on request. I was looking if this is the
way to go. Any alternative ideas..? Thanks for your time.
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
Thanks for the response. I tried following and I am getting this exception, what am I missing. I have a successful connection.
IContributorManager icm = repository.contributorManager();
IContributor user = icm.fetchContributorByUserId("st1", monitor);
user.setName("test2");
user.setUserId("test2");
user.setEmailAddress("test2");
icm.saveContributor(user, monitor);
I am counting that the saveContributor will create a new user. I can't find a way to instantiate the IContributor without reading from the IContributorManager.
The exception I get is:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2047)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:247)
at com.ibm.team.repository.common.model.impl.ContributorImpl.setNameGen(ContributorImpl.java:352)
at com.ibm.team.repository.common.model.impl.ContributorImpl.setName(ContributorImpl.java:338)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:596)
at $Proxy7.setName(Unknown Source)
at snippets.Snippet1.login(Snippet1.java:66)
at snippets.Snippet1.main(Snippet1.java:31)
IContributorManager icm = repository.contributorManager();
IContributor user = icm.fetchContributorByUserId("st1", monitor);
user.setName("test2");
user.setUserId("test2");
user.setEmailAddress("test2");
icm.saveContributor(user, monitor);
I am counting that the saveContributor will create a new user. I can't find a way to instantiate the IContributor without reading from the IContributorManager.
The exception I get is:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2047)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:247)
at com.ibm.team.repository.common.model.impl.ContributorImpl.setNameGen(ContributorImpl.java:352)
at com.ibm.team.repository.common.model.impl.ContributorImpl.setName(ContributorImpl.java:338)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:596)
at $Proxy7.setName(Unknown Source)
at snippets.Snippet1.login(Snippet1.java:66)
at snippets.Snippet1.main(Snippet1.java:31)
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
I gave another shot.
Contributor contrib = RepositoryFactory.eINSTANCE.createContributor();
contrib.setUserId("test2");
contrib.setName("test2");
contrib.setEmailAddress("test2");
........
icm.saveContributor(contrib, monitor);
...
Exception in thread "main" java.lang.IllegalArgumentException: The contributor is not a working copy
at com.ibm.team.repository.client.internal.ContributorManager.saveContributor(ContributorManager.java:76)
at snippets.Snippet1.login(Snippet1.java:83)
at snippets.Snippet1.main(Snippet1.java:35)
I forgot to mention, I am writing a plain java client
Contributor contrib = RepositoryFactory.eINSTANCE.createContributor();
contrib.setUserId("test2");
contrib.setName("test2");
contrib.setEmailAddress("test2");
........
icm.saveContributor(contrib, monitor);
...
Exception in thread "main" java.lang.IllegalArgumentException: The contributor is not a working copy
at com.ibm.team.repository.client.internal.ContributorManager.saveContributor(ContributorManager.java:76)
at snippets.Snippet1.login(Snippet1.java:83)
at snippets.Snippet1.main(Snippet1.java:35)
I forgot to mention, I am writing a plain java client
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
After getworkingcopy() a user is created but it cannot log in.
When I log in as ADMIN, and navigate to User Management page and click the newly created user to see details, I get this message.
This user is not in the directory service. The user will not be able to login unless they an account in the directory service.
What is this directory service? How to access it from the client API?
Thanks again.
When I log in as ADMIN, and navigate to User Management page and click the newly created user to see details, I get this message.
This user is not in the directory service. The user will not be able to login unless they an account in the directory service.
What is this directory service? How to access it from the client API?
Thanks again.
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
How is the license assignments particularly newly created users handled? I am playing with LicenseAssignment from RepositoryFactory where I see a setLicense method but I don't think its enough. I tried printing a getLicense and obviously it is 0 because it is created new. How do I stuff com.ibm.team.rtc.developer or com.ibm.team.rtc.contributor client access so I exhaust all the licenses. Thanks.
![](http://jazz.net/_images/myphoto/6896a44922841807c39bc22b903c2c45.jpg)
There is not a supported Java API for assigning assigning licenses. The
best way to assign a license to a contributor is to take the same
approach as the web UI and use the ILicenseAdminRestService to request
the assignment. I would look at the HTTP calls that the web UI makes
and learn how to do the same thing.
-
Matt Lavin
Jazz Server Team
On Tue, 2008-11-04 at 15:27 +0000, warade wrote:
best way to assign a license to a contributor is to take the same
approach as the web UI and use the ILicenseAdminRestService to request
the assignment. I would look at the HTTP calls that the web UI makes
and learn how to do the same thing.
-
Matt Lavin
Jazz Server Team
On Tue, 2008-11-04 at 15:27 +0000, warade wrote:
How is the license assignments particularly newly created users
handled? I am playing with LicenseAssignment from RepositoryFactory
where I see a setLicense method but I don't think its enough. I tried
printing a getLicense and obviously it is 0 because it is created new.
How do I stuff com.ibm.team.rtc.developer or
com.ibm.team.rtc.contributor client access so I exhaust all the
licenses. Thanks.
page 1of 1 pagesof 2 pagesof 3 pages