It is currently Thu Oct 29, 2020 9:17 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Copy Files to a Samba Share
PostPosted: Wed Aug 02, 2006 10:13 am 
Offline
User
User

Joined: Fri Aug 29, 2003 7:47 am
Posts: 44
Location: Germany
I want to write a PB Win Software, which have to copy files to a Samba Directory.

The User who was logged in at the WinPC and who works with my PB Software doesn´t have any rights to the Samba-Share! It is not allowed that the user has access to this directory, except to copy a file with my software!

So my Software must copy the files with a account who has this rights to write a file in the samba share.

How can I do this?
A function like CopyFile(source$,dest$,username$,password$) ;-) doesn´t exist.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 02, 2006 3:03 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Sep 16, 2004 9:50 pm
Posts: 658
Location: France
Try this ( PB 3.94 Code ) :

Code:
ProcedureDLL WNetAddConnectionNT(Username.s,Password.s,ShareName.s,DriveLetter.s,Persistant.l)
 
  ;/ Username / Password
  ;/ Sharename : \\Server\Share
  ;/ DriveLetter : F:
  ;/ Persistant : #True or #False
  ;/ Return 1 if success or 0 if fail
 
  lpNetResource.NETRESOURCE
  lpNetResource\dwtype=1 ; RESOURCETYPE_DISK
  lpNetResource\lpLocalName=@DriveLetter
  lpNetResource\lpRemoteName=@ShareName
 
  OpenLibrary(0,"Mpr.dll")
  retour=CallFunction(0,"WNetAddConnection2A",lpNetResource,Password,Username,Persistant)
  CloseLibrary(0)
 
  If retour=0 : retour=1 : Else : retour=0 : EndIf
  ProcedureReturn retour
 
EndProcedure


ProcedureDLL WNetCancelConnection(DriveLetter.s,force.l)
 
  ; Driveletter : Ex F:
  ; Force = #True or #False ( Deconnect when file is in use )
 
  OpenLibrary(0,"Mpr.dll")
  retour=CallFunction(0,"WNetCancelConnectionA",DriveLetter,force)
  CloseLibrary(0)
  If retour=0 : retour=1 : Else : retour=0 : EndIf
  ProcedureReturn retour
EndProcedure

_________________
DroopyLib/PBFastLib/HMod


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 03, 2006 10:35 am 
Offline
User
User

Joined: Fri Aug 29, 2003 7:47 am
Posts: 44
Location: Germany
Thanks for the code droopy! It works fine!

but it will be my last recource because I don´t want to assign a drive letter with code overhead (Letter free ....).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Majestic-12 [Bot] and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye