IAccountServiceSaveAccount Method |
Namespace: Dundas.BI.AccountServices
Exception | Condition |
---|---|
ArgumentNullException | account is . |
ValidationException | account contains invalid property values. If the password does not meet the application's complexity requirements, the exception's error code will be 2710. |
DuplicateItemException | An account with the specified name already exists. |
NotSupportedException | The Save operation is not supported by the underlying accounts provider. -or- The account is associated with a tenant, but the multi-tenancy features of the application are not enabled. |
NotFoundException | The account with the specified ID does not exist. -or- The tenant associated with the account does not exist. |
LicenseExceededException | There are no more available reserved seats of the kind set in the account. |
NoPrivilegeException | The caller does not have system administration privileges. -or- The account is associated with a tenant, and the caller does not have administration privileges for that tenant. |
InvalidSessionException | The caller context is not associated with a valid session. |
This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, create a local user account, and then shutdown the Dundas BI engine.
using Dundas.BI; using Dundas.BI.AccountServices; using Dundas.BI.Services; using System.Collections.ObjectModel; ... // Create the engine. EngineManager.CreateEngine( // Path to the application's data folder. Type: System.String @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data" ); try { // Start the Dundas BI Engine. EngineManager.StartEngine(); // Create a caller context not associated with any session. using(Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null)) { // LogOn. LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn( // The account name. Type: System.String "admin", // The password. Type: System.String "1234", // Delete other sessions for the logon to succeed. Type: System.Boolean true, // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo null ); // Set the current session ID. using(Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId( logOnResult.Session.Id ); // Get the account service. IAccountService accountService = Engine.Current.GetService<IAccountService>(); // Define the local user account. LocalUserAccount account = new LocalUserAccount("JohnSmith", "1234"); // Define some properties account.EmailAddress = "JohnSmith@dundas.com"; account.DisplayName = "John Smith"; account.SeatKind = Dundas.BI.Licensing.LicenseSeatKind.StandardUser; account.IsSeatReserved = true; // Save the account. accountService.SaveAccount(account); } } finally { EngineManager.ShutdownEngine(); }
This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, create a windows user account, and then shutdown the Dundas BI engine.
using Dundas.BI; using Dundas.BI.AccountServices; using Dundas.BI.Services; using System.Collections.ObjectModel; ... // Create the engine. EngineManager.CreateEngine( // Path to the application's data folder. Type: System.String @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data" ); try { // Start the Dundas BI Engine. EngineManager.StartEngine(); // Create a caller context not associated with any session. using(Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null)) { // LogOn. LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn( // The account name. Type: System.String "admin", // The password. Type: System.String "1234", // Delete other sessions for the logon to succeed. Type: System.Boolean true, // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo null ); // Set the current session ID. using(Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId( logOnResult.Session.Id ); // Get the account service. IAccountService accountService = Engine.Current.GetService<IAccountService>(); // Define the windows user account. WindowsUserAccount account = new WindowsUserAccount("dundas", "johns"); // Define some properties account.EmailAddress = "JohnS@dundas.com"; account.DisplayName = "John Smith"; account.SeatKind = Dundas.BI.Licensing.LicenseSeatKind.StandardUser; account.IsSeatReserved = true; // Save the account. accountService.SaveAccount(account); } } finally { EngineManager.ShutdownEngine(); }
This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, create a windows user group account, and then shutdown the Dundas BI engine.
using Dundas.BI; using Dundas.BI.AccountServices; using Dundas.BI.Services; using System.Collections.ObjectModel; ... // Create the engine. EngineManager.CreateEngine( // Path to the application's data folder. Type: System.String @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data" ); try { // Start the Dundas BI Engine. EngineManager.StartEngine(); // Create a caller context not associated with any session. using(Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null)) { // LogOn. LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn( // The account name. Type: System.String "admin", // The password. Type: System.String "1234", // Delete other sessions for the logon to succeed. Type: System.Boolean true, // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo null ); // Set the current session ID. using(Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId( logOnResult.Session.Id ); // Get the account service. IAccountService accountService = Engine.Current.GetService<IAccountService>(); // Create a windows group account. WindowsGroupAccount groupAccount = new WindowsGroupAccount("dundas", "newemployees"); // Set some properties groupAccount.DisplayName = "New Employees"; // Save the account. accountService.SaveAccount(groupAccount); } } finally { EngineManager.ShutdownEngine(); }