UserManipulation

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Use)
Line 20: Line 20:
 
==AllowCreateUser==
 
==AllowCreateUser==
  
Setting AllowCreateUser = true will expose the create user XMLRPC function. Here's an example python program of how to call this.  It assumes that your ROBUST services are running on localhost.
+
Here's an example python program to call this.  It assumes that your ROBUST services are running on localhost.
  
 
<source lang="python">
 
<source lang="python">
Line 28: Line 28:
 
import urllib
 
import urllib
  
params = urllib.urlencode({'METHOD':'createuser', 'FirstName':'Fred', 'LastName':'Flintstone', 'Password':'test', 'PrincipalID':'3a1c8128-908f-4455-8157-66c96a46f75e'})
+
params = urllib.urlencode({'METHOD':'createuser', 'FirstName':'Jon', 'LastName':'Snow', 'Password':'test', 'PrincipalID':'3a1c8128-908f-4455-8157-66c96a46f75e'})
 
conn = httplib.HTTPConnection("localhost", 8003);
 
conn = httplib.HTTPConnection("localhost", 8003);
 
conn.request("POST", "/accounts", params)
 
conn.request("POST", "/accounts", params)
Line 57: Line 57:
  
 
Don't worry about ScopeID, this is used for allow multiple grids to co-exist inside a single database.  Created is a unix timestamp of the time the user was created.  UserLevel determines whether the user is a god (>= 200) or can log in at all (<0).  ServiceURLs are HyperGrid related and do not concern us here.
 
Don't worry about ScopeID, this is used for allow multiple grids to co-exist inside a single database.  Created is a unix timestamp of the time the user was created.  UserLevel determines whether the user is a god (>= 200) or can log in at all (<0).  ServiceURLs are HyperGrid related and do not concern us here.
 +
 +
If the call fails you will get the response
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?>
 +
<ServerResponse>
 +
  <result>Failure</result>
 +
</ServerResponse>
 +
</source>
 +
 +
==AllowSetAccount==
 +
 +
Here's an example python program to call this.  It assumes that your ROBUST services are running on localhost.
 +
 +
<source lang="python">
 +
#!/usr/bin/python
 +
 +
import httplib
 +
import urllib
 +
 +
params = urllib.urlencode({'METHOD':'setaccount', 'FirstName':'Tyrion', 'PrincipalID':'3a1c8128-908f-4455-8157-66c96a46f75e'})
 +
conn = httplib.HTTPConnection("localhost", 8003);
 +
conn.request("POST", "/accounts", params)
 +
response = conn.getresponse()
 +
print response.read();
 +
</source>
 +
 +
PrincipalID is the unique ID of the user.  Here, it is used to identify the user that we set up earlier.
 +
 +
If everything goes well, you should get back
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?>
 +
<ServerResponse>
 +
  <result type="List">
 +
    <FirstName>Tyrion</FirstName>
 +
    <LastName>Snow</LastName>
 +
    <Email/>
 +
    <PrincipalID>3a1c8128-908f-4455-8157-66c96a46f75e</PrincipalID>
 +
    <ScopeID>00000000-0000-0000-0000-000000000000</ScopeID>
 +
    <Created>1318974501</Created>
 +
    <UserLevel>0</UserLevel>
 +
    <UserFlags>0</UserFlags>
 +
    <ServiceURLs>HomeURI*;GatekeeperURI*;InventoryServerURI*;AssetServerURI*;</ServiceURLs>
 +
  </result>
 +
</ServerResponse>
 +
</source>
 +
 +
Note that the first name has now changed from Jon to Tyrion.
  
 
If the call fails you will get the response
 
If the call fails you will get the response

Revision as of 17:00, 8 June 2012

Contents

Introduction

Normally, users are created in OpenSimulator via the "create user" command on the region console (in standalone configuration) or on the ROBUST service console (in grid configuration). However, users can also be created by making an XMLRPC call directly to the ROBUST service. This facility has been available since OpenSimulator 0.7.3. It can currently only be used in grid configuration.

Setup

The listener for the createuser XMLRPC call on ROBUST has to be explicitly enabled. In the [UserAccountService] section of Robust.ini, set

[UserAccountService]
AllowCreateUser = true
AllowSetAccount = true

AllowCreateUser allows users to be created via an XMLRPC call. AllowSetAccount allows user account details to be changed afterwards (change name, user level, etc.). You can enable both or just one or the other.

Please be aware that this will expose the call on the UserAccountServiceConnector as listed in the ServiceConnectiors parameter in the [Startup] section at the top of the file. The default port used (8003) is one that should not be exposed to other users. For logging into OpenSimulator you only need to expose the port that is running the LLLoginServiceInConnector (8002 by default).

Use

AllowCreateUser

Here's an example python program to call this. It assumes that your ROBUST services are running on localhost.

#!/usr/bin/python
 
import httplib
import urllib
 
params = urllib.urlencode({'METHOD':'createuser', 'FirstName':'Jon', 'LastName':'Snow', 'Password':'test', 'PrincipalID':'3a1c8128-908f-4455-8157-66c96a46f75e'})
conn = httplib.HTTPConnection("localhost", 8003);
conn.request("POST", "/accounts", params)
response = conn.getresponse()
print response.read();

PrincipalID is the unique ID of the user.

If everything goes well, you should get back

<?xml version="1.0"?>
<ServerResponse>
  <result type="List">
    <FirstName>Fred</FirstName>
    <LastName>Flintstone</LastName>
    <Email/>
    <PrincipalID>3a1c8128-908f-4455-8157-66c96a46f75e</PrincipalID>
    <ScopeID>00000000-0000-0000-0000-000000000000</ScopeID>
    <Created>1318974501</Created>
    <UserLevel>0</UserLevel>
    <UserFlags>0</UserFlags>
    <ServiceURLs>HomeURI*;GatekeeperURI*;InventoryServerURI*;AssetServerURI*;</ServiceURLs>
  </result>
</ServerResponse>

Don't worry about ScopeID, this is used for allow multiple grids to co-exist inside a single database. Created is a unix timestamp of the time the user was created. UserLevel determines whether the user is a god (>= 200) or can log in at all (<0). ServiceURLs are HyperGrid related and do not concern us here.

If the call fails you will get the response

<?xml version="1.0"?>
<ServerResponse>
  <result>Failure</result>
</ServerResponse>

AllowSetAccount

Here's an example python program to call this. It assumes that your ROBUST services are running on localhost.

#!/usr/bin/python
 
import httplib
import urllib
 
params = urllib.urlencode({'METHOD':'setaccount', 'FirstName':'Tyrion', 'PrincipalID':'3a1c8128-908f-4455-8157-66c96a46f75e'})
conn = httplib.HTTPConnection("localhost", 8003);
conn.request("POST", "/accounts", params)
response = conn.getresponse()
print response.read();

PrincipalID is the unique ID of the user. Here, it is used to identify the user that we set up earlier.

If everything goes well, you should get back

<?xml version="1.0"?>
<ServerResponse>
  <result type="List">
    <FirstName>Tyrion</FirstName>
    <LastName>Snow</LastName>
    <Email/>
    <PrincipalID>3a1c8128-908f-4455-8157-66c96a46f75e</PrincipalID>
    <ScopeID>00000000-0000-0000-0000-000000000000</ScopeID>
    <Created>1318974501</Created>
    <UserLevel>0</UserLevel>
    <UserFlags>0</UserFlags>
    <ServiceURLs>HomeURI*;GatekeeperURI*;InventoryServerURI*;AssetServerURI*;</ServiceURLs>
  </result>
</ServerResponse>

Note that the first name has now changed from Jon to Tyrion.

If the call fails you will get the response

<?xml version="1.0"?>
<ServerResponse>
  <result>Failure</result>
</ServerResponse>
Personal tools
General
About This Wiki