Password: String;
The Password property determines a password of the user, under whom the connection is established.
The property is write-only.
Executing the example requires EditBox1 and EditBox2 of EditBox type on the form. The schema must contain a table with the Table identifier. The user, under whom the connection is established, should be added to a list of repository users and should have the Login and the Read and Write Permission for All Objects privileges.
Add links to the Db and Metabase system assemblies.
Sub UserProc;
Var
MbDef: IMetabaseDefinition;
Package: ISecurityPackage;
PC: IPasswordCredentials;
Mb: IMetabase;
MbManager: IMetabaseManager;
Table: ITable;
Field: ITableField;
Begin
Mb := Null;
MbManager := MetabaseManagerFactory.Active;
MbDef := MbManager.Definitions.FindById("Warehouse");
Debug.AssertMsg(MbDef <> Null, "Repository description is not found");
Package := MbManager.Packs.FindById(MbDef.SecurityPackage).Package;
PC := Package.CreateCredentials(AuthenticationMode.Password) As IPasswordCredentials;
PC.UserName := EditBox1.Text;
PC.Password := EditBox2.Text;
Mb := MbDef.Open(PC, ApplicationMode.Win, LocaleCodeID.Russian);
WinApplication.InformationBox("Connection is established");
Table := Mb.ItemById("Table").Bind As ITable;
For Each Field In Table.Fields Do
Debug.WriteLine(Field.Name);
End For;
End Sub UserProc
If the correct password and user name are entered, the connection to the Warehouse schema is established, and the message about it is displayed. Names of table fields are displayed in the console window.
See also: