How to programmatically add a new user to Trident

Oct 20, 2010 at 5:31 AM

Hi, there

How can we programmatically add a new user to Trident by bypassing the user validating process?

Cheers

 

 

Oct 20, 2010 at 10:30 AM

Hi,

Thanks for your interest in Trident.

We are looking into your concern. We will keep you posted on updates. 

Regards,
Trident Support Team

Oct 26, 2010 at 2:31 PM
Edited Oct 26, 2010 at 2:33 PM
Hi,
 
You can create the user programmatically by following the below steps.
 
       1.   Create a user in Trident registry:
User user = User.Create(model.Name.Trim(), this.registryConnection);
if (!string.IsNullOrEmpty(model.Description))
{
  user.Description = model.Description.Trim();
}
 
user.IsBuiltin = false;
user.Enabled = model.Status;
user.Save();
 
2.   Create Workflow Category for the user:
TridentAuthentication.CreateMyWorkflowCategory(user, this.registryConnection);
 
3.   Assign User to the specific User Credentials:
UserCredential userCredential = UserCredential.Create(<<Credential_Name>>, CredentialType.Windows, user, this.registryConnection);
userCredential.DisplayName = <<CredentialDisplayName>>;
userCredential.Save();
 
4.   Assign User to the specific groups:
Group group = Group.Load(<<GroupName>>;, this.registryConnection);
user.Groups.Add(group);
 
5.  Assign User to specific Roles:
SystemPolicy policy = SystemPolicy.Get(this.registryConnection);
You can add the user to the following set of roles.
a.  Trident Users: policy.TridentUsers.Add(user);
b.  Trident Administrators: policy.TridentAdministrators.Add(user);
c.  Trident guests: policy.TridentGuests.Add(user);
d.  Trident services: policy.TridentServices.Add(user);
 
6.   Grant the User Credential with registry access: This is to make sure that the user credential which we are adding the 3 Step has the permission to access the trident registry.
 
 
 
Note: But we would highly recommend NOT to create user manually. Please use Trident Management studio to add a new user to Trident.
If the steps are not followed in sequence or if their are some problems while executing theses steps. Then this could lead some inconsistencies in Trident Registry. Also there is a possibility that you might have difficulty/will not be able to connect to Trident registry.
 
Please let us know if you have any further questions/clarifications.
Thanks,
Trident Support Team
Oct 28, 2010 at 3:06 PM

Hi,

Can you please let us know if our response helped in answering your questions?

Thanks,
Trident Support Team

Oct 31, 2010 at 12:53 AM

Thanks for your advice.

The reason why we cannot use ManagermentStudio to add users is our client has very strict IT policy.  Domain users dont have local administrator priviliges and also they cannot get the permission to start/stop window service. 

We can temporaily get the local administrator's password, and install Trident on local machine.  However,  when we tried to add DOMAIN USER into Trident by local administrator, it was denied, local adminsitrator cannot access DOMAIN USER's info.

That is why we need a way to bypass the user account validation.

 

Oct 31, 2010 at 12:55 AM
Edited Oct 31, 2010 at 12:56 AM

These codes work well, unless one:

TridentAuthentication.CreateMyWorkflowCategory(registryConnection);

Where is TridentAuthentication?  I t seems not in Microsoft.Research.TridentAuthentication.dll

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Another question is:  These codes add  a user to Trident.  I have found this user is not in SQL Express Login.  Do I need to mannually create a SQL login account for this user, or Trident has a way to add SQL login?

Cheers

 

Nov 3, 2010 at 1:14 PM
Hi,
 
<< Where is TridentAuthentication? >>
You can find TridentAuthentication type in Microsoft.Research.ScientificWorkflow.TridentUtilities.dll.
 
<< Do I need to mannually create a SQL login account for this user, or Trident has a way to add SQL login?>>
No. Trident can create a create SQL login programmatically using the function RegistryManagerService.GrantRegistryAccess. Following code snippet explains on how to use it with the context of User.
 
this.GrantRegistryAccess(user);
 
Please let us know if this answers your questions.
Thanks,
Trident Support Team
Nov 9, 2010 at 10:02 AM

Hi,

Can you please let us know if our response helped in answering your questions?

Regards,
Trident Support Team

Nov 9, 2010 at 9:32 PM

It works. Many thanks

Nov 11, 2010 at 2:22 AM

BTW:

How can we programmatically import a workflow [twp] into a category?

Cheers

 

 

Nov 11, 2010 at 4:29 PM

Hi,

We are looking into your question. We will keep you posted on updates. 

Regards, 
Trident Support Team

Nov 12, 2010 at 11:30 AM

Hi,
 
Please find the answer to your question below:

<<How can we programmatically import a workflow [twp] into a category?>> 
 
The basic steps for importing a workflow package are:

1. Extract the xoml and the dependent assemblies from the twp file
2. Import the workflow(represented by the xoml and the dependencies) to Registry.
 
We can programmatically import a workflow (twp) into a category by following the below steps:
 
 1. Extract the xoml and the dependent assemblies from the twp file:

     a. Extract the xoml and the dependencies from the workflow [twp] into a categoryby following the below steps:
         Collection<string> selectedFiles = new Collection<string>();
         selectedFiles = new Collection<string>(<<TWP File Path>>.ToList());
         selectedFiles = Helper.ExtractPackage(selectedFiles[0], <<packageTempDirectory>>, false);


2. Import the workflow(represented by the xoml and the dependencies) to Registry:
 
      a. Load the dependencies into another AppDomain
           BuildReferencesProxy proxy = new BuildReferencesProxy(fileReferences, selectedFiles, <<TempDirectory>>);
           Collection<FileReference> filerefs = proxy.Execute();
 
      b. Assign the workflow category along with other Workflow Properties
           WorkflowProperties wfProperties = new WorkflowProperties();
           this.wfProperties.Name = <<Workflow Name>>;
           this.wfProperties.IsInteractive=<<true/false>>;
           this.wfProperties.CategoryId=<<Category Guid>>;
 
      c. Create a ImportWorkflow Proxy and add the workflow to the registry
             ImportWorkflowProxy importWorkflow = new ImportWorkflowProxy(wfProperties, filerefs, this.registryConnection, TridentAuthentication.LoggedUserInUserName);
             Guid wfId = importWorkflow.Execute();
             importStatus = wfId == Guid.Empty ? false : true;
             if (importStatus.Value)
             {
                       UiHelper.AddMetadata(wfId, <<TWP File Path>>, false);
              }
 
      d. Delete the temporary folder
          Directory.Delete(<<TempDirectory>>, true);
 
Please let us know if you have any questions/clarifications.
Regards,
Trident Support Team

Nov 21, 2010 at 11:25 PM

Great!

Many thanks