UserStation: String;
The UserStation property determines a name of the user workstation to write it into the access protocol.
The name is set in the form: domain\workstation. If this property is set to non-empty on setting accounts, the specified value will be used to check workstation locking and to write to access protocol, otherwise name of the workstation with the running process is used.
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 whose profile the connection is established, must be added to the repository users list and must have the Login and Right for Reading and Opening All Objects privileges.
Sub UserProc;
Var
MbDef: IMetabaseDefinition;
Package: ISecurityPackage;
PC: IPasswordCredentials;
Mb: IMetabase;
MbManager: IMetabaseManager;
Table: ITable;
Field: ITableField;
Begin
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;
PC.UserStation := "WORK\PCTest";
Mb := MbDef.Open(PC, ApplicationMode.Win, LocaleCodeID.Russian);
Debug.WriteLine("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 password and user name are correct, the connection to the specified repository is established, provided that the specified workstation name is an allowed workstation for the user. When the connection is established successfully the corresponding notification is displayed. Names of table fields are displayed in a console window.
See also: