Leadtools.Medical.Workstation.DataAccessLayer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
SetUserPassword Method
See Also  Example
Leadtools.Medical.Workstation.DataAccessLayer Namespace > IWorkstationDataAccessAgent Interface : SetUserPassword Method



adminUser
The administrator user name performing the operation.
adminPassword
The administrator user password performing the operation.
userName
The user name which password will be updated.
newPassword
A SecureString holding the new password for the user.
adminUser
The administrator user name performing the operation.
adminPassword
The administrator user password performing the operation.
userName
The user name which password will be updated.
newPassword
A SecureString holding the new password for the user.
Updates an existing user password.

Syntax

Visual Basic (Declaration)  
Overridable Function SetUserPassword( _
   ByVal adminUser As String, _
   ByVal adminPassword As SecureString, _
   ByVal userName As String, _
   ByVal newPassword As SecureString _
) As Boolean
Visual Basic (Usage) Copy Code
Dim instance As IWorkstationDataAccessAgent
Dim adminUser As String
Dim adminPassword As SecureString
Dim userName As String
Dim newPassword As SecureString
Dim value As Boolean
 
value = instance.SetUserPassword(adminUser, adminPassword, userName, newPassword)
C#  
virtual bool SetUserPassword( 
   string adminUser,
   SecureString adminPassword,
   string userName,
   SecureString newPassword
)
C++/CLI  
virtual bool SetUserPassword( 
   String^ adminUser,
   SecureString^ adminPassword,
   String^ userName,
   SecureString^ newPassword
) 

Parameters

adminUser
The administrator user name performing the operation.
adminPassword
The administrator user password performing the operation.
userName
The user name which password will be updated.
newPassword
A SecureString holding the new password for the user.

Return Value

True if the user password is updated; otherwise it is false.

Example

Visual Basic Copy Code
<Test> _
Public Sub CreateDbUser()
  Dim dataAccessAgent As IWorkstationDataAccessAgent = Nothing
  Try
     'make sure you have configured the application configuration file with a valid
     'SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection'
     dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent("WorkstationSqlCeConnection")

     If Nothing Is dataAccessAgent Then
       Console.WriteLine("You have not configured a valid database connection.")

       Return
     End If
  Catch exception As Exception
     Console.WriteLine(exception.Message," :You have not configured a valid database connection.")

     Return
  End Try

  Dim administratorUser As String = "Administrator" 'make sure you have an existent administrator this administrator user should be created when you create the database.
  Dim newUserName As String = "NewUser"
  Dim adminPassword As SecureString = New SecureString()
  Dim newUserPassword As SecureString = New SecureString()

  adminPassword.AppendChar("a"c)
  adminPassword.AppendChar("d"c)
  adminPassword.AppendChar("m"c)
  adminPassword.AppendChar("i"c)
  adminPassword.AppendChar("n"c)

  newUserPassword.AppendChar("u"c)
  newUserPassword.AppendChar("s"c)
  newUserPassword.AppendChar("e"c)
  newUserPassword.AppendChar("r"c)

  dataAccessAgent.AddUser(administratorUser, adminPassword, newUserName, newUserPassword, False)

  Console.WriteLine("Is User Authenticated:", newUserName, dataAccessAgent.IsUserValid(newUserName, newUserPassword))
  Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName))

  dataAccessAgent.SetAdminUser(administratorUser, adminPassword, newUserName, True)

  Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName))

  dataAccessAgent.SetUserPassword(administratorUser, adminPassword, newUserName, adminPassword)

  Dim users As User() = dataAccessAgent.GetUsers()

  Console.WriteLine("Listing all database users...")

  For Each dbUser As User In users
     Console.WriteLine(dbUser.UserName)
  Next dbUser

  adminPassword.Dispose()
  newUserPassword.Dispose()
End Sub
C# Copy Code
public void CreateDbUser() 

   IWorkstationDataAccessAgent dataAccessAgent = null ; 
 
   try 
   { 
      //make sure you have configured the application configuration file with a valid  
      //SqlCe connection string which have the same connection name 'WorkstationSqlCeConnection' 
      dataAccessAgent = DataAccessAgentFactory.Instance.CreateAccessAgent("WorkstationSqlCeConnection"); 
 
      if (null == dataAccessAgent) 
      { 
         Console.WriteLine("You have not configured a valid database connection."); 
 
         return; 
      } 
   } 
   catch ( Exception exception ) 
   { 
      Console.WriteLine( exception.Message," :You have not configured a valid database connection."); 
 
      return ; 
   } 
 
   string administratorUser = "Administrator";//make sure you have an existent administrator this administrator user should be created when you create the database. 
   string newUserName = "NewUser"; 
   SecureString adminPassword = new SecureString(); 
   SecureString newUserPassword = new SecureString(); 
 
   adminPassword.AppendChar('a'); 
   adminPassword.AppendChar('d'); 
   adminPassword.AppendChar('m'); 
   adminPassword.AppendChar('i'); 
   adminPassword.AppendChar('n'); 
 
   newUserPassword.AppendChar('u'); 
   newUserPassword.AppendChar('s'); 
   newUserPassword.AppendChar('e'); 
   newUserPassword.AppendChar('r'); 
 
   dataAccessAgent.AddUser(administratorUser, adminPassword, newUserName, newUserPassword, false); 
 
   Console.WriteLine("Is User Authenticated:", newUserName, dataAccessAgent.IsUserValid(newUserName, newUserPassword)); 
   Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName)); 
 
   dataAccessAgent.SetAdminUser(administratorUser, adminPassword, newUserName, true); 
 
   Console.WriteLine("Is User Administrator:", newUserName, dataAccessAgent.IsAdmin(newUserName)); 
 
   dataAccessAgent.SetUserPassword(administratorUser, adminPassword, newUserName, adminPassword); 
 
   User [ ] users = dataAccessAgent.GetUsers(); 
 
   Console.WriteLine("Listing all database users..."); 
 
   foreach (User dbUser in users) 
   { 
      Console.WriteLine(dbUser.UserName); 
   } 
 
   adminPassword.Dispose(); 
   newUserPassword.Dispose(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

Leadtools.Medical.Workstation.DataAccessLayer requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features