Home > Forum > Database > Attachments saving in a different place

Attachments saving in a different place
0

Hi,

I have a project where I can't save attachment in a webcon database storage(becouse of company policies). I am looking for a solution to store attachments on network drive.

Is there possibility to change localization of attachment ?

May be some workaround? Some action, rule, ect?

I thought about action which will create a folder on shared drive and webcon form will show information to user where to store attachment. But I don't know how to achieve this:/

Any idea?

MVP

Hi Darek,

the simplest way to create the folder would be to use the PowerShell action. Here are two examples;
https://stackoverflow.com/questions/5226772/powershell-create-folder-on-remote-server/23550226

You could generate the link in advance, store it in a field and pass it to the script. I'm not sure which user executes the script. You could write the user name to a file so that you can grant the required privileges on the shared folder.

I'm not sure whether a user can click on an URL of the file protocol. I tested it once and it was either blocked by the browser oder the field itself. If it's blocked by the browser you could create a custom protocol which you need to deploy to all users:
https://www.vdoo.com/blog/exploiting-custom-protocol-handlers-in-windows

With this you could open explorer.exe and pass the path of the shared folder

Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Darek,

the simplest way to create the folder would be to use the PowerShell action. Here are two examples;
https://stackoverflow.com/questions/5226772/powershell-create-folder-on-remote-server/23550226

You could generate the link in advance, store it in a field and pass it to the script. I'm not sure which user executes the script. You could write the user name to a file so that you can grant the required privileges on the shared folder.

I'm not sure whether a user can click on an URL of the file protocol. I tested it once and it was either blocked by the browser oder the field itself. If it's blocked by the browser you could create a custom protocol which you need to deploy to all users:
https://www.vdoo.com/blog/exploiting-custom-protocol-handlers-in-windows

With this you could open explorer.exe and pass the path of the shared folder

Best regards,
Daniel

Hello Daniel,

I thought about this and tried to use Powershell action but without success. The script works with Webcon service account.
It works and I am able to create folder/file on a server side but this is not my point. I have to create a folder in a specific localization, on the different server.

I think the problem is in our AD structure. Webcon BPS works on server 'X' in domain 'Y' and I want to create a folder on server 'A' in domain 'B'.
I gave webcon user privilege to shared folder on server 'A' in domain 'B' but it still doesn't work. I got error: "Username or password is incorrect'
I left UserName and password filed blank in powershell action so it should work on webcon user context...

I don't know what can I do anything else:/

MVP
In reply to: Marek

Hello Daniel,

I thought about this and tried to use Powershell action but without success. The script works with Webcon service account.
It works and I am able to create folder/file on a server side but this is not my point. I have to create a folder in a specific localization, on the different server.

I think the problem is in our AD structure. Webcon BPS works on server 'X' in domain 'Y' and I want to create a folder on server 'A' in domain 'B'.
I gave webcon user privilege to shared folder on server 'A' in domain 'B' but it still doesn't work. I got error: "Username or password is incorrect'
I left UserName and password filed blank in powershell action so it should work on webcon user context...

I don't know what can I do anything else:/

Hi Darek,

did you succeed in creating the folder via UI using ino the service account (rdp login with service account on the webcon server)?

If this works you should also be able to create the folder using one of these scripts from the stack overflow question:
Webcon service has permission
UNC path works as well with New-Item

$ComputerName = "fooComputer"
$DriveLetter = "D"
$Path = "fooPath"
New-Item -Path FileSystem::\\$ComputerName\$DriveLetter$\$Path -type directory -Force

Other credentials:
$c = Get-Credential -Credential
$s = $ExecutionContext.InvokeCommand.NewScriptBlock("mkdir c:\NewDir")
Invoke-Command -ComputerName PC01 -ScriptBlock $s -Credential $c

Alternatively you could try to add the location as a Network drive for the service account and use the drive letter to create the folder


Once one of these approaches work in the ISE, started as WEBCON service account, it should also work as an action.

Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Darek,

did you succeed in creating the folder via UI using ino the service account (rdp login with service account on the webcon server)?

If this works you should also be able to create the folder using one of these scripts from the stack overflow question:
Webcon service has permission
UNC path works as well with New-Item

$ComputerName = "fooComputer"
$DriveLetter = "D"
$Path = "fooPath"
New-Item -Path FileSystem::\\$ComputerName\$DriveLetter$\$Path -type directory -Force

Other credentials:
$c = Get-Credential -Credential
$s = $ExecutionContext.InvokeCommand.NewScriptBlock("mkdir c:\NewDir")
Invoke-Command -ComputerName PC01 -ScriptBlock $s -Credential $c

Alternatively you could try to add the location as a Network drive for the service account and use the drive letter to create the folder


Once one of these approaches work in the ISE, started as WEBCON service account, it should also work as an action.

Best regards,
Daniel

"did you succeed in creating the folder via UI using ino the service account (rdp login with service account on the webcon server)"
Yes, I am able to create a folder on disc C:\ on server.

Any other way doesn't work.

I think I do something wrong but maybe let's try another way.
Let's say that I want to create a folder on my local disk C:\ How to do this?

In a configuration of powershell action there is a place where I can type my credentials. If I am correct If I type there my username and password I should be able to create a directory on my local drive. I tried on many ways but without success. Can you write a powershell script which will work?

I read this https://howto.webcon.com/powershell-action/ article and they say that It should works with user context...

MVP

I've just tested this from within PowerShell ISE:

$ComputerName = "GLDTC-*"
$path = "D$\temp123"
$createdFolder = New-Item -Path "FileSystem::\\$ComputerName\$Path" -type directory -Force
Write-Host "Current server $env:COMPUTERNAME"
Write-Host "Folder created $($createdFolder.FullName)"

"D$" is an admin share I used for this test and it worked fine. In addition I tried to create a folder via a networks share which is mapped to drive "z" connected via different credentials.
$createdFolder = New-Item -Path "z:\Path123" -type directory -Force

This worked too.

In reply to: Daniel Krüger (Cosmo Consult)

I've just tested this from within PowerShell ISE:

$ComputerName = "GLDTC-*"
$path = "D$\temp123"
$createdFolder = New-Item -Path "FileSystem::\\$ComputerName\$Path" -type directory -Force
Write-Host "Current server $env:COMPUTERNAME"
Write-Host "Folder created $($createdFolder.FullName)"

"D$" is an admin share I used for this test and it worked fine. In addition I tried to create a folder via a networks share which is mapped to drive "z" connected via different credentials.
$createdFolder = New-Item -Path "z:\Path123" -type directory -Force

This worked too.

Daniel,

I think It works for you because you created the folder on a server where BPS is installed. The same action works form me fine and I can create whatever I want( on server where BPS is installed).

I want to create a folder on my client computer. When I type your script I got error: "The path is not of a legal form".
This is what I paste into powershell action in BPS:

$ComputerName = "10.16.218.101"
$path = "D$\temp123"
$createdFolder = New-Item -Path "FileSystem::\\$ComputerName\$Path" -type directory -Force
Write-Host "Current server $env:COMPUTERNAME"
Write-Host "Folder created $($createdFolder.FullName)"

I run powershell on my computer and paste it there too, works fine.

MVP
In reply to: Marek

Daniel,

I think It works for you because you created the folder on a server where BPS is installed. The same action works form me fine and I can create whatever I want( on server where BPS is installed).

I want to create a folder on my client computer. When I type your script I got error: "The path is not of a legal form".
This is what I paste into powershell action in BPS:

$ComputerName = "10.16.218.101"
$path = "D$\temp123"
$createdFolder = New-Item -Path "FileSystem::\\$ComputerName\$Path" -type directory -Force
Write-Host "Current server $env:COMPUTERNAME"
Write-Host "Folder created $($createdFolder.FullName)"

I run powershell on my computer and paste it there too, works fine.

Hi Darek,

my example didn't involve BPS. Did you receive the error when the script has been executed as a BPS action or executing it with PowerShell only.

In the later case you should probably involve someone at your company who knows about setting up network shares and who can check whether the connection between both servers are working at all. I get the impression that this isn't your area of expertise. Perhaps you should also start to create a folder using the windows explorer on the other server. If this works than it will also be possible to achieve this using PowerShell.

Best regards,
Daniel