To create a new database user, use the TBConnection.CreateTopobaseUser() method. This method takes as one of its parameters a Connection object that corresponds to the current user name and password.
The following code snippet shows how to open a connection and create a database user:
// Create a new empty Oracle user.
string userName = Properties.Settings.Default.Oracle_User;
if (!this.Application.Connection.ExistsUser(userName))
{
// Project settings store the new database and password.
using (Autodesk.Map.IM.Data.TBConnection myConnection =
new Autodesk.Map.IM.Data.TBConnection(
Properties.Settings.Default.Oracle_User,
Properties.Settings.Default.Oracle_Password,
this.Application.Connection.DataSource,
true,
this.Application.Connection))
{
try
{
myConnection.CreateTopobaseUser(
this.Application.Connection,
"USERS",
"TEMP",
"USERS");
}
catch (Autodesk.Map.IM.Exception.TBException ex)
{
if (ex.Caller == Autodesk.Map.IM.Exception.TBExceptionCaller.TB3Server)
{
MessageBox.Show("Unable to create user:"
+ Environment.NewLine + ex.Message);
}
else
{
throw;
}
}
finally
{
myConnection.Close();
}
}
}
else
{
MessageBox.Show("User already exists.");
}