EnableUNCAccess Function

Action

Enables a virtual user to access files that are located on UNC paths. Call this function in the initial transaction of your test script.

Include file

Kernel.bdh

Syntax

EnableUNCAccess( in sHost     : string,
                 in sUserName : string,
                 in sPassword : string ): boolean;

Return value

  • true if successful.

  • false otherwise.

Parameter Description
sHost Name of the computer where the file is located.
sUserName Name of a Windows NT/2000 domain user. For remote access, a user who has appropriate permissions on the remote computer must be specified.
sPassword Password of the Windows NT/2000 domain user.

Example

dcltrans
  transaction TInit
  begin
    EnableUNCAccess("lab13", "testdomain\\user1", "pass1");
  end TInit;

  transaction AccessUncPath
  var
    hFile : number;
    sOutput : string;
  begin
    // create new file
    FOpen(hFile, "\\\\lab13\\exportdir\\dummyfile.txt",
    OPT_FILE_ACCESS_READWRITE, OPT_FILE_CREATE);
    writeln("new file created");

    // write string to file
    sOutput := "Hello world!";
    FWrite(hFile, sOutput);
    writeln("string written to file");

    // close file
    FClose(hFile);
    writeln("file closed");
  end AccessUncPath;