IAccountServiceDeleteAccount Method |
Namespace: Dundas.BI.AccountServices
Exception | Condition |
---|---|
ArgumentException | id is Empty. |
NotFoundException | The account with the specified ID does not exist. |
NotSupportedException | The operation is not supported by the underlying accounts provider. |
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. |
InvalidOperationException | An attempt was made to delete the built-in administrator account. |
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, deletes an account with the ID = fdcb7aa9-8d5b-4a78-a9a6-745695928328, and then calls the shutdown engine method.
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>(); // Delete the account. accountService.DeleteAccount(new Guid("fdcb7aa9-8d5b-4a78-a9a6-745695928328")); } } finally { EngineManager.ShutdownEngine(); }