Password: String;
The Password property determines a password of the user, under whom the connection is established.
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("p5bash");
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
When specifying correct user password and name connection to the "p5bash" scheme is established, a message about it is displayed. Names of table fields are displayed in the console window.
See also: