Pure-ftp and file ownership

Hello,
I am running a oes2 server with pure-ftp. Everything is running fine with pure-ftp when login in with FileZilla or ftp command line, but I als have a ncp volume mapped to the ftp location on the server. When people in my organization put files in the ftp directories via the ncp connections ownership of the files will be of those who put them there and not the ownership of the ftp user which owns the ftp directory on the server.
Is it possible to configure the server/pure-ftp or ncp to change the ownership of the file from edit user to ftp user.
Regards

I will answer from the pure-ftpd perspective: There is not anything pure-ftpd can do to solve this issue.
You could develop a cron script that would frequently traverse these directories and chown the file according to your desires.
I don't have much experience on the NCP side, but if your real concern about ownership is that someone else needs permissions, then maybe setting a different umask in the NCP volume settings would grant more permissions to more people, and solve your issue that way.

Similar Messages

  • Pure ftp and trusedip

    How do I enable multiple trusted IP address within Pure-FTP?
    The pure-ftpd.conf states:
    # Only connections to this specific IP address are allowed to be
    # non-anonymous. You can use this directive to open several public IPs for
    # anonymous FTP, and keep a private firewalled IP for remote administration.
    # You can also only allow a non-routable local IP (like 10.x.x.x) to
    # authenticate, and keep a public anon-only FTP server on another IP.
    #TrustedIP 10.1.1.1
    The example shows one IP address. I've tried:
    TrustedIP 192.168.10.* for the whole subnet, but a restart of pure-ftp give an error stating it doesn't like the line.
    I've tried 192.168.10.x as the explanation displays, no good, same error.
    After this is working, then, the next question will be to trust multiple IP addresses, actually, a subnet and several single IP addresses.
    Any suggestions? Examples?
    Thank you.

    Originally Posted by brunold
    One configs seems to override the other one.
    Just as a test, can you place the NoAnonymous behind the trustedip option in the config file and try again ?
    Rainer
    Thank You for the Info.
    I put 'NoAnonymous yes' and 'AnonymousOnly no' below the 'TrustedIP 192.168.10.240 192.168.10.241' line. It did not help.
    This is the welcome from the ftp server
    220-You are user number 1 of 10 allowed.
    220-Only anonymous FTP is allowed here
    220 You will be disconnected after 15 minutes of inactivity.
    So I commented the 'TrusedIP' to keep anonymous out.
    Any more suggestions.
    Is this designed, a BUG, or what.
    Is there a way to have trusted IP addresses and keep anonymous out?

  • Using JCA FTP and File Adapters to transfer files as attachments

    I am trying to develop a flow that picks a file up using the JCA FTP adapter and writes it using the JCA File Adapter. I can get this to work using opaqeElement but the issue I have is that the files that will be transferred are regularly very large > 1 GB and using the opaqueElement simply results in a OutOfMemoryException.
    Reading the Adapter documentation it seems that Reading/Writing file as an attachment may be an answer. I therefore did the following.
    . Created FTP Read and File Write adapters in JDeveloper
    . Inmported this in to OEPE
    . Created Proxy Service and Business Service and wired them together
    The problem i am having is that even though there is no error and the file is being read on the FTP server, the resulting file only contains that attachment details, the file is not a copy of the file that was picked up from the ftp server.
    I am assuming that this behaviour is not correct and that the file should be transferred in its entirity. Unfortunatly the documentation is not very detailed and I cannot find any examples on the internet.
    Can anyone offer any advice or even better suggest where I can find an example.
    Regards
    My JCA adapters are as follows:
    FileWriteAsAttachmentAdapter_file
    <adapter-config name="FileWriteAsAttachmentAdapter" adapter="File Adapter"
         wsdlLocation="FileWriteAsAttachmentAdapter.wsdl"
         xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/HAFileAdapter"/>
    <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
    <property name="PhysicalDirectory" value="C:\fileserver\download\toprocess"/>
    <property name="Append" value="false"/>
    <property name="FileNamingConvention" value="attachment_%SEQ%.csv"/>
    <property name="NumberMessages" value="1"/>
    </interaction-spec>
    </endpoint-interaction>
    </adapter-config>
    FileWriteAsAttachmentAdapter.wsdl
    <wsdl:definitions
    name="FileWriteAsAttachmentAdapter"
    targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/AtatchmentApp/Project1/FileWriteAsAttachmentAdapter"
    xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/AtatchmentApp/Project1/FileWriteAsAttachmentAdapter"
    xmlns:imp1="http://xmlns.oracle.com/pcbpel/adapter/file/attachment/"
    xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    >
    <plt:partnerLinkType name="Write_plt" >
    <plt:role name="Write_role" >
    <plt:portType name="tns:Write_ptt" />
    </plt:role>
    </plt:partnerLinkType>
    <wsdl:types>
    <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/attachment/" xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" >
    <element name="attachmentElement" >
    <complexType>
    <attribute name="href" type="string" />
    </complexType>
    </element>
    </schema>
    </wsdl:types>
    <wsdl:message name="Write_msg">
    <wsdl:part name="body" element="imp1:attachmentElement"/>
    </wsdl:message>
    <wsdl:portType name="Write_ptt">
    <wsdl:operation name="Write">
    <wsdl:input message="tns:Write_msg"/>
    </wsdl:operation>
    </wsdl:portType>
    </wsdl:definitions>
    FtpGetAsAttachmentAdapter_ftp.jca
    <adapter-config name="FtpGetAsAttachmentAdapter" adapter="FTP Adapter"
         wsdlLocation="FtpGetAsAttachmentAdapter.wsdl"
         xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/ftp/TlmsHAFtpAdapter"/>
    <endpoint-activation portType="Get_ptt" operation="Get">
    <activation-spec className="oracle.tip.adapter.ftp.inbound.FTPActivationSpec">
    <property name="AsAttachment" value="true"/>
    <property name="DeleteFile" value="true"/>
    <property name="MinimumAge" value="300"/>
    <property name="PhysicalDirectory" value="/ftp/tlms2atas"/>
    <property name="Recursive" value="false"/>
    <property name="FileModificationTime" value="FileSystem"/>
    <property name="PollingFrequency" value="60"/>
    <property name="FileType" value="ascii"/>
    <property name="IncludeFiles" value=".*[_][0-9][0-9][-][0-9][0-9][-][0-9][0-9][_].*\.csv"/>
    <property name="UseHeaders" value="false"/>
    <property name="ModificationTimeFormat" value="dd/MM/yyyy HH:mm"/>
    </activation-spec>
    </endpoint-activation>
    </adapter-config>
    FtpGetAsAttachmentAdapter.wsdl
    <wsdl:definitions
    name="FtpGetAsAttachmentAdapter"
    targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/AtatchmentApp/Project1/FtpGetAsAttachmentAdapter"
    xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/ftp/AtatchmentApp/Project1/FtpGetAsAttachmentAdapter"
    xmlns:attach="http://xmlns.oracle.com/pcbpel/adapter/file/attachment/"
    xmlns:pc="http://xmlns.oracle.com/pcbpel/"
    xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    >
    <plt:partnerLinkType name="Get_plt" >
    <plt:role name="Get_role" >
    <plt:portType name="tns:Get_ptt" />
    </plt:role>
    </plt:partnerLinkType>
    <wsdl:types>
    <schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/file/attachment/" xmlns="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified" >
    <element name="attachmentElement" >
    <complexType>
    <attribute name="href" type="string" />
    </complexType>
    </element>
    </schema>
    </wsdl:types>
    <wsdl:message name="Get_msg">
    <wsdl:part name="attach" element="attach:attachmentElement"/>
    </wsdl:message>
    <wsdl:portType name="Get_ptt">
    <wsdl:operation name="Get">
    <wsdl:input message="tns:Get_msg"/>
    </wsdl:operation>
    </wsdl:portType>
    </wsdl:definitions>

    System resources are finite and have a threshold limit for processing. The Oracle SOA Suite, dependent on system resources, also has certain size limitations, largely due to the underlying resources beyond which the system cannot process incoming requests.
    For example, Oracle JCA Adapters can process large payloads but the Oracle BPEL PM consumes huge memory when processing large payloads, which can cause OutOfMemory conditions and affect the whole system.
    You can try File ChunkedRead option.This will read your large CSV file in chunks so chances of memory out will be less. You can define your own chunk size.
    This is a feature of Oracle File and FTP Adapters that uses an invoke activity within a while loop to process the target file. This feature enables you to process arbitrarily
    large files. See below link's section "4.5.5 Oracle File Adapter ChunkedRead"
    http://www.orastudy.com/oradoc/selfstu/fusion/integration.1111/e10231/adptr_file.htm#BABDIABG
    Thanks,
    Ashu

  • FTP and File problems

    I have Dreamweaver 8. Trying to manage a little league
    website- not real computer savvy.
    All of the files an folders in my panel group (right hand
    column) are gone. Any idea on how I might get that back. I now have
    to go up to 'file' drop down menu, choose 'open' and all folders
    and file names are listed. Much easier when they were all on the
    right column. Have no idea why they are gone.
    I am also now getting a message everytime I try to update
    something........ " FTP error occurred, cannot make connection to
    host. Your login or password is incorrect". I am putting in the
    correct password.
    I recently updated to Windows Exp 7.0 and wonder if that had
    anything to do with this program changing.
    Thanks
    Karen

    > I recently updated to Windows Exp 7.0 and wonder if that
    had anything to
    > do
    > with this program changing.
    Yes - probably did. There are hundreds of posts here about
    issues after
    installing IE7. Have you updated to DW 8.0.2? Please do that
    before doing
    anything else.
    Then, you need to create a new site definition for your site.
    Clearly your
    current definition has become hosed. That's a simple thing to
    do.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "kwilson333" <[email protected]> wrote in
    message
    news:elhplt$2m0$[email protected]..
    >
    >
    > I have Dreamweaver 8. Trying to manage a little league
    website- not real
    > computer savvy.
    >
    > All of the files an folders in my panel group (right
    hand column) are
    > gone.
    > Any idea on how I might get that back. I now have to go
    up to 'file' drop
    > down
    > menu, choose 'open' and all folders and file names are
    listed. Much
    > easier
    > when they were all on the right column. Have no idea why
    they are gone.
    >
    > I am also now getting a message everytime I try to
    update
    > something........ "
    > FTP error occurred, cannot make connection to host. Your
    login or
    > password is
    > incorrect". I am putting in the correct password.
    >
    > I recently updated to Windows Exp 7.0 and wonder if that
    had anything to
    > do
    > with this program changing.
    >
    > Thanks
    > Karen
    >

  • Ftp and File polling

    Hi
    Do anyone have sample code for file polling.
    i am using linux environment.
    If any client ftp a file i have to poll the file and parse the file csv , if file is parsed and good then send to oracle database and archive the file.
    I have to do everything java
    if one had done this kind of application, send me the sample code.
    Thanks in advance
    sami

    Actually client using any ftp client programm and send or ftp a file on the my ftp server from there i have to check which file is new for every 1hour and i have to take that file, parse (csv parse) and insert the data to oracle database and archive the file, if file is good otherwise i have to send email to some dept saying file is bad.
    could u have any idea or sample code.
    Thanks
    sami

  • FTP and "File-in-use"

    Dear all,
    We have a scenario in which a file is written to the SAP application server which should be picked up by XI using the FTP adapter. The polling interval of the adapter is set to 60 seconds.
    We running into a strange problem: it may occur that the program on the SAP application server is still busy writing the dataset to the server, however the file already exists (as soon as the OPEN DATASET statement is passed the file is created on the application server but with no content yet). If just at this time the interval of 60 seconds is passed the FTP-adapter picks up the empty file, does no processing because the file is empty, but still archives the file to an archive directory.
    Obviously the OPEN DATASET does not put an exclusive lock to the file? Does anyone know a solution to this?
    Kind regards,
    John.

    Hi,
    use .tmp extension to the file untill it completes writing the data, then change it to original extension.
    for eg: if it is a .txt file then use .tmp untill the file is written and then change it to .txt this is not a big logic at SAP, just renaming the file after completing the write.
    Regards,
    Karan.

  • Browsing is very slow on Mac Mini connected to 100mbit LAN. FTP and file download is very fast.

    Hi all
    I have a strange behaviour of my Mac MIni 2012. The mini is connected to the internet by LAN. When I download a file via http or ftp everything is very fast (arround 95mbit/s). But when I try to open a website in Safari, Chrome or Firefox i have to wait some seconds until the page starts rendering.after the page is rendered completely, everything works fast and smooth.
    Do you have any ideas where the problem migth be? I have reinstalled Mavericks from zero yesterday. The problem resists. With my Macbook Air (conntected to the same router) and my Windows computer I dont have this problem.
    THanks in advance for your help.
    Greets
    Marc

    By any chance, do you run sophos?  I had the same issue as you and fixed it on my mac mini and macbook pro by doing the following:
    Sophos --> Open Preferences --> Web Protection --> General
    You will need to enter your admin password after clicking the padlock in the bottom left to allow you to change settings.
    From there, deactivate "Block access to malicious websites using realtime URL reputation checks".  For good measure, I also deactivated "Block malicious downloads from websites".
    Hope this helps!

  • Mac OS X Server and Pure-FTP: error in OS X Server Sdmin

    Hi all.
    Recently I installed an XServe to serve different needs:
    It's a File service, Web service, Windows Service, Print Service AND, I supposed, a nice FTP service.
    Simply I had to allow few people that don't belong to the company, to "ftp's" document from outside.
    The FTP module with the OSXServer core is really UGLY and absolutely not flexible so I preferred to move to an OpenSource program to substitute it.
    I choosed Pure-FTP.
    It works very fine BUT I saw something wrong in the ADMIN app of Mac OS X Server: the service FTP "looks like" running!
    Also the button at the top of the window shows the service running; if I stop it, the PURE-FTP application stops to work!
    Anyone has found this situation or anyone is using this app program on an XServe?

    If you are using PureFTP, then use it.
    Server Admin is NOT designed to work in conjunction with non-Apple, 3rd-party products, or non-Apple configs of 3rd-party items such as Postfix or Amavisd, and certainly not for non-Apple-provided ftp services. Ignore Server Admin completely for FTP if you are using PureFTP.
    End of story

  • Unable to download from AppStore, updates,etc.Messages 'the installer is damaged' to 'there might be a problem with file ownership and permissions.' I am the owner and only user of a new MBP. What could be going on?

    Is anyone having the same type of problems I'm having with Lion. I have a new MacBook Pro, received 7 weeks ago, preinstalled with Leopard 10.6.7. I didn't migrate anything from my old iMac, wanted a clean install from the Apple Store. While there, I asked for the upgrade to Lion 10.7, however their system was down.
    I  installed it myself, wirelessly about a week later, and Apple emailed me a receipt. Now, I've had to call support directly last week when I lost Mail, Address Book, was unable to open Preview or iTunes, among other problems. Seemed fixed after a session that baffled even the store tech.  Now I am unable to download or install the recent Mac updates for Lion, from the App Store, could not install Adobe Reader, etc. Messages range from 'A network error has occured - Check your Internet connection and try again' to 'The Installer is damaged and cannot open the package. There may be a problem with file ownership or permissions.'  All fail and I'll probably have to call Apple again. I am frustrated beyond words.  Logs 'Install's runner tool is not properly configured as a setuid tool', domain errors, 'attempt to write a readonly database, and on and on. I have barely done a thing on this computer except search online for help with these problems. Safari gives me a 'You are not connected to the internet' too often. Diagnostics disagrees. I do see wi-fi problems in the forum. Disk and permissions were fine at the beginning of the earlier problems, checked first by support tech. I'm not sure if support tech even knew. I was just happy they were fixed. Anyone have these download and/or install problems after a 'clean bill of health' so to speak, only a week ago?

    Let's try the following user tip with that one:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • Task or script to monitor file ownership, permissions and change as needed

    I'm using a Mac OS X Tiger (10.4.9) computer as a file server for a group of people who are (1) individually non-administrative users and (2) members of Groups. The hard drive is partitioned into 2 volumes: Vol1 has no non-admin access, Vol2 has a Shared folder containing folders with files intended for either Public or Private access. I'm admin with UID=501 and trying not to be a danger. Each other user has a unique UID. Each Group has a unique GID. The folder that all users have access to is named Pub_shares. Every user allowed to access Pub_shares is a member of PubGroup (GID=505).
    Now when a user accesses a file nested in Pub_shares, that file usually becomes owned by that user and the group membership may change from PubGroup and may undergo a change to "Read only" or "No Access." Since all members of PubGroup should have Read & Write access to files in Pub_shares, this is a problem. All files in Pub_shares, regardless of who last touched them, should remain:
    Owner = chris / Access Read & Write
    Group = PubGroup / Access Read & Write
    Others = No Access
    I've read some about Ownership & Permissions. I've seen it suggested that an admin set up an automated task, say to run every 3 minutes; that task checks file ownership and permissions and, if different, changes the values recursively to those shown above, such that:
    Owner = 501 / Access = rwx
    Group = 505 / Access = rwx
    What do I need here? An Automator workflow? A shell script? AppleScript? Cron? launchd? How do I put this together? I don't know the syntax or the expressions to use. Any help is much much appreciated. [Note again: My "server" runs Tiger 10.4.9.] Thanks.

    ..."I have some Windows users (trying) to access shared files. Will the afp inheritance options stand up to a Windows user?"...
    No the afp inherit settings won't apply to windows sharing, but I think there are equivalent settings that can be applied to smb.
    ..."I thought, too, I'd read somewhere that inheritance options use the topmost volume folder to set inheritance patterns."...
    I am not able to double-check this for Tiger, but I don't think that is the case. As far as I know, with those settings enabled (and it doesn't work reliably if only one is enabled) permissions and ownership should be inherited from the folder that the items are added to.
    ..."My topmost folder on vol2 is "Shared" but it contains both Pub_shares (accessible by members of PubGroup) and a few Private_shares (folders accessible by members of various private groups)."...
    Sorry I missed that point in your earlier post. The above would cause complications if a user were to move items from the private area to the public area. The inheritance only applies to when files are created, so something moved from the private area to the public area would retain its original permissions. To make it work, the public and private areas would have to be set up as separate shares, rather sharing the whole volume.

  • Sapevt and file adapter using ftp

    Hi;
    Using the file adapter, I ftp a file to our SAP R/3 system called T01 (=SID).
    Target directory
    //T01/010/OCS/TC/IN
    File name scheme:
    wka.dat
    I specify in "Run Operating System Command After Message Processing"
    sapevt WKA -t name=T01 nr=01
    WKA is the event I defined (SM62) into our T01 R/3 system.
    It seems not to work. Any help? Did I miss something?
    Where do I need to search for logging (ABAP or J2EE stack)?
    Wilbert

    Hi Wilbert,
    Please check these...
    http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    FTP ReceiverChannel and OS commands help
    Hope these help!
    cheers,
    Prashanth
    P.S Please mark helpful answers

  • Need help for Scheduling a Spool file and FTP the file

    I have one requirement like below...
    1. Start Scheduling a job
    2. Generate a Spool file (.csv file)
    3. If Spool file generation is successful then start FTP the file
    Else End job
    4. After successful FTP process end the job.
    We need to create a log file also for this job.
    Can any body give some idea how will i proceed?
    Thanks in advance.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Chris' may be wrapped, but it includes the funky ability to query remote files directly in SQL due to it's use of pipelined functions. A feature I've also got in my own FTP package and very useful for monitoring logs on remote servers through our Apex applications. ;)Ditto - also rolled my own FTP package as doing wildcard file listing requires custom support depending on the type of FTP server you're dealing with. The text part of the responses differ (these are not RFC'ed) and makes parsing more complex than what it could have been.Yeah, the differing responses can be a pain, though fortunately they are far and few between. There was a bug in Chris' package in that it wasn't handling a two code response from a windows FTP server for one of the commands, but I emailed him and he fixed that. Not his fault, he didn't have a windows FTP server to test on at the time.
    FTP is a pretty straight forward protocol and easy to wrap a PL/SQL package around (using <i>UTL_TCP</i>).Absolutely. and the RFC details almost everthing you need to handle. It was quite quick to knock up a package, similar to the code hoek has linked to.
    I think there is a lot of common stuff that many of us do in this regard. Always wondered how well a proper GPL'ed open source project providing a PL/SQL development framework and libraries would do...I think there'd be a lot of arguments about what is the best way of doing things. :D

  • Pull compressed file (.gz format) via FTP and place on Application server

    Hello!
    Greetings.
    We have a requirement where a compressed file in the format *.gz is to be pulled via FTP and saved to the application server after extracting.
    I searched the forums and found options to pull text or XL files, but nothing about pulling a compressed file. I wished to know if there is any process for the same. After pulling the file, it is to be saved to Application server after extracting. My doubts are as below:
    1. How to pull a *.gz file via FTP (Need batch processing)
    2. Can I extract and rename th file before saving it to applciation server? Or I need a temporary location to place the file before extraction?
    Any inputs are appreciated.
    Thanks,
    Shishir.

    Hi Sandra.
    Thanks for the confirmation.
    There is a change is the requirement. We need to Poll the FTP server for the file for the duration of one week every month.
    When the file is found, we are to take the *.gz file, extract and put on the application server.
    My question is how do we poll the application FTP server? I searched  the forums and found a few threads that say that an FTP adapter is to be setup for polling the FTP server and then we can schedule it using u201CAvailability Time Planningu201D.
    /people/shabarish.vijayakumar/blog/2006/11/26/adapter-scheduling--hail-sp-19-
    I wished to know if that is the only way to approach this requirement.
    Any help is appreciated.
    Thanks and Regards,
    Shishir.
    Edited by: Shishir Kinkar on Apr 26, 2011 11:07 AM

  • Taking Ownership of folders and files

    So I am doing what sure seems like way too much work to do something rather simple in GUI. There seem to be many topics on this and I base my code off of their results, but it isn't working entirely. Hopefully an easy one for you folks!  I am trying
    to take ownership of a path, be it a file or folder.  I DO NOT want to use a separate module like PSCX as not all machines will have the module.
    I created a function based off the code I found at the end of
    http://social.technet.microsoft.com/Forums/en-US/87679d43-04d5-4894-b35b-f37a6f5558cb/ that I can pass a path to singularly or I was hoping to be able to pipe Get-ChildItem to it.  When I do "Get-ChildItem -Path D:\Permissions\TopFolder -Recurse
    -Force | Take-Ownership" it seemed to work, but then I noticed it only seems to work going one layer deep. The text output for troubleshooting shows it recursing all the way through, but yet Owner is not being set all the way down.
    Folder layout:
    D:\Permissions\TopFolder
    D:\Permissions\TopFolder\FirstFolder
    D:\Permissions\TopFolder\FirstFile.txt
    D:\Permissions\TopFolder\FirstFolder\SecondFolder
    D:\Permissions\TopFolder\FirstFolder\SecondFile.txt
    D:\Permissions\TopFolder\FirstFolder\SecondFolder\ThirdFolder
    D:\Permissions\TopFolder\FirstFolder\SecondFolder\ThirdFile.txt
    Function Take-Ownership {
    [CmdletBinding(DefaultParameterSetName=”Set01”)]
    Param(
    [parameter(Mandatory=$true,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True,Position=1,ParameterSetName='Set01')]
    [string]$Path,
    [parameter(Mandatory=$true,ValueFromPipelinebyPropertyName=$True,ParameterSetName='Set02')]
    [Alias('FullName')][string]$FullPath
    ) # End of Param()
    Begin {
    # Check that script was Run as Administrator
    If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Write-Host -ForegroundColor Red -BackgroundColor Black "`n ERROR: You MUST have Administrator rights to run this script!"
    Write-Host -ForegroundColor Red -BackgroundColor Black " Re-run this script as an Administrator!`n"
    Break
    #P/Invoke'd C# code to enable required privileges to take ownership and make changes when NTFS permissions are lacking
    $AdjustTokenPrivileges = @"
    using System;
    using System.Runtime.InteropServices;
    public class TokenManipulator
    [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
    internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
    ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
    [DllImport("kernel32.dll", ExactSpelling = true)]
    internal static extern IntPtr GetCurrentProcess();
    [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
    internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr
    phtok);
    [DllImport("advapi32.dll", SetLastError = true)]
    internal static extern bool LookupPrivilegeValue(string host, string name,
    ref long pluid);
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    internal struct TokPriv1Luid
    public int Count;
    public long Luid;
    public int Attr;
    internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
    internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
    internal const int TOKEN_QUERY = 0x00000008;
    internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
    public static bool AddPrivilege(string privilege)
    try
    bool retVal;
    TokPriv1Luid tp;
    IntPtr hproc = GetCurrentProcess();
    IntPtr htok = IntPtr.Zero;
    retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
    tp.Count = 1;
    tp.Luid = 0;
    tp.Attr = SE_PRIVILEGE_ENABLED;
    retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
    retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
    return retVal;
    catch (Exception ex)
    throw ex;
    public static bool RemovePrivilege(string privilege)
    try
    bool retVal;
    TokPriv1Luid tp;
    IntPtr hproc = GetCurrentProcess();
    IntPtr htok = IntPtr.Zero;
    retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
    tp.Count = 1;
    tp.Luid = 0;
    tp.Attr = SE_PRIVILEGE_DISABLED;
    retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
    retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
    return retVal;
    catch (Exception ex)
    throw ex;
    Add-Type $AdjustTokenPrivileges
    # Activate necessary admin privileges to make changes without NTFS perms on the folder
    [void][TokenManipulator]::AddPrivilege("SeRestorePrivilege") # Necessary to set Owner Permissions
    [void][TokenManipulator]::AddPrivilege("SeBackupPrivilege") # Necessary to bypass Traverse Checking
    [void][TokenManipulator]::AddPrivilege("SeTakeOwnershipPrivilege") # Necessary to override File Permissions
    $Admin = New-Object System.Security.Principal.NTAccount("BUILTIN\Administrators")
    $NewDirACL = New-Object System.Security.AccessControl.DirectorySecurity
    $NewFileACL = New-Object System.Security.AccessControl.FileSecurity
    $NewDirACL.SetOwner($Admin)
    $NewFileACL.SetOwner($Admin)
    } # End of Begin {}
    Process {
    if( $FullPath.Length -gt 0 ) {
    if( Test-Path $FullPath ) {
    $Path = $FullPath
    if( Test-Path $Path -PathType Container ) {
    "Take Ownership: $Path"
    $Folder = Get-Item $Path -Force
    $Folder.SetAccessControl($NewDirACL)
    } elseif( Test-Path $Path -PathType Leaf ) {
    "Take Ownership: $Path"
    $File = Get-Item $Path -Force
    $File.SetAccessControl($NewFileACL)
    } else {
    Write-Host -ForegroundColor Red -BackgroundColor Black "ERROR: Path does not exist: $Path"
    } # End of Process {}
    End { } # End of End {}
    } # End of Function Take-Ownership
    To run this I have been doing:
    PS D:\> $Folder = 'D:\Permissions\TopFolder'
    PS D:\> Get-Item $Folder | Get-Acl
    Directory: D:\Permissions
    Path Owner
    TopFolder DOMAIN\user1
    PS D:\> Get-ChildItem $Folder -Force -Recurse | Get-Acl
    Directory: D:\Permissions\TopFolder
    Path Owner
    FirstFolder DOMAIN\user1
    FirstFile.txt DOMAIN\user1
    Directory: D:\Permissions\TopFolder\FirstFolder
    Path Owner
    SecondFolder DOMAIN\user1
    SecondFile.txt DOMAIN\user1
    Directory: D:\Permissions\TopFolder\FirstFolder\SecondFolder
    Path Owner
    ThirdFolder DOMAIN\user1
    ThirdFile.txt DOMAIN\user1
    PS D:\>
    PS D:\> Get-Item $Folder | Take-Ownership
    Take Ownership: D:\Permissions\TopFolder
    PS D:\> Get-ChildItem $Folder -Force -Recurse | Take-Ownership
    Take Ownership: D:\Permissions\TopFolder\FirstFolder
    Take Ownership: D:\Permissions\TopFolder\FirstFile.txt
    Take Ownership: D:\Permissions\TopFolder\FirstFolder\SecondFolder
    Take Ownership: D:\Permissions\TopFolder\FirstFolder\SecondFile.txt
    Take Ownership: D:\Permissions\TopFolder\FirstFolder\SecondFolder\ThirdFolder
    Take Ownership: D:\Permissions\TopFolder\FirstFolder\SecondFolder\ThirdFile.txt
    PS D:\>
    PS D:\>
    PS D:\> Get-Item $Folder | Get-Acl
    Directory: D:\Permissions
    Path Owner
    TopFolder BUILTIN\Administrators
    PS D:\> Get-ChildItem $Folder -Force -Recurse | Get-Acl
    Directory: D:\Permissions\TopFolder
    Path Owner
    FirstFolder BUILTIN\Administrators
    FirstFile.txt BUILTIN\Administrators
    Directory: D:\Permissions\TopFolder\FirstFolder
    Path Owner
    SecondFolder DOMAIN\user1
    SecondFile.txt DOMAIN\user1
    Directory: D:\Permissions\TopFolder\FirstFolder\SecondFolder
    Path Owner
    ThirdFolder DOMAIN\user1
    ThirdFile.txt DOMAIN\user1
    PS D:\>
    I don't know why this isn't working.  The output text shows I went through the subfolders and files...HELP!
    Find this post helpful? Does this post answer your question? Be sure to mark it appropriately to help others find answers to their searches.

    Here is the end result. I am looking to add a '-Recurse'/'-Force' switches to give another option to not have to Get-ChildItem and pipe it to the function and possibly a '-User' parameter to be able to specify who to set as owner, but both of those ideas
    are untested.
    Here is the code.  Hope it helps someone else.
    Function Take-Ownership {
    <#
    .SYNOPSIS
    This function takes ownership of a file or folder and sets it back to 'BUILTIN\Administrators'.
    .DESCRIPTION
    This function takes ownership of a file or folder and sets it back to 'BUILTIN\Administrators'.
    This will work even when the user does not have ownership or existing permissions on the file or folder.
    .EXAMPLE
    PS C:\> Take-Ownership -Path $Path
    Takes ownership of the individual folder or file. The -Path is optional as long as $Path
    is the first parameter.
    .EXAMPLE
    PS C:\> Get-Item $Path | Take-Ownership
    Takes ownership of the individual folder or file.
    .EXAMPLE
    PS C:\> Get-ChildItem $Path -Recurse -Force | Take-Ownership
    Recurse through all folders and files, including hidden, and takes ownership.
    #>
    [CmdletBinding()]
    Param(
    [parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelinebyPropertyName = $True, Position = 0)]
    [Alias('FullName')]
    [string]$Path
    ) # End of Param()
    Begin {
    # Check that script was Run as Administrator
    If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Write-Host -ForegroundColor Red -BackgroundColor Black "`n ERROR: You MUST have Administrator rights to run this script!"
    Write-Host -ForegroundColor Red -BackgroundColor Black " Re-run this script as an Administrator!`n"
    Return
    #P/Invoke'd C# code to enable required privileges to take ownership and make changes when NTFS permissions are lacking
    $AdjustTokenPrivileges = @"
    using System;
    using System.Runtime.InteropServices;
    public class TokenManipulator
    [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
    internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
    ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
    [DllImport("kernel32.dll", ExactSpelling = true)]
    internal static extern IntPtr GetCurrentProcess();
    [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
    internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr
    phtok);
    [DllImport("advapi32.dll", SetLastError = true)]
    internal static extern bool LookupPrivilegeValue(string host, string name,
    ref long pluid);
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    internal struct TokPriv1Luid
    public int Count;
    public long Luid;
    public int Attr;
    internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
    internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
    internal const int TOKEN_QUERY = 0x00000008;
    internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
    public static bool AddPrivilege(string privilege)
    try
    bool retVal;
    TokPriv1Luid tp;
    IntPtr hproc = GetCurrentProcess();
    IntPtr htok = IntPtr.Zero;
    retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
    tp.Count = 1;
    tp.Luid = 0;
    tp.Attr = SE_PRIVILEGE_ENABLED;
    retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
    retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
    return retVal;
    catch (Exception ex)
    throw ex;
    public static bool RemovePrivilege(string privilege)
    try
    bool retVal;
    TokPriv1Luid tp;
    IntPtr hproc = GetCurrentProcess();
    IntPtr htok = IntPtr.Zero;
    retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
    tp.Count = 1;
    tp.Luid = 0;
    tp.Attr = SE_PRIVILEGE_DISABLED;
    retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
    retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
    return retVal;
    catch (Exception ex)
    throw ex;
    Add-Type $AdjustTokenPrivileges
    # Activate necessary admin privileges to make changes without NTFS perms on the folder
    [void][TokenManipulator]::AddPrivilege("SeRestorePrivilege") # Necessary to set Owner Permissions
    [void][TokenManipulator]::AddPrivilege("SeBackupPrivilege") # Necessary to bypass Traverse Checking
    [void][TokenManipulator]::AddPrivilege("SeTakeOwnershipPrivilege") # Necessary to override File Permissions
    } # End of Begin {}
    Process {
    # Process for taking Ownership of the folder
    # - Specify the NT Account user to set as Owner (BUILTIN\Administrators)
    # - Create a new ACL object for the sole purpose of defining a new owner
    # - Establish the new ACL as owned by BUILTIN\Administrators, thus
    # guaranteeing the following ACL changes can be applied.
    # - Then apply that update to the existing folder's ACL which merges
    # the proposed changes (new owner) into the folder's actual ACL
    # - - IN OUR CASE OVERWRITING THE OWNER
    # - Additional Documentation:
    # http://msdn.microsoft.com/en-us/library/System.Security.AccessControl(v=vs.110).aspx
    $Admin = New-Object System.Security.Principal.NTAccount("BUILTIN\Administrators")
    $NewDirACL = New-Object System.Security.AccessControl.DirectorySecurity
    $NewFileACL = New-Object System.Security.AccessControl.FileSecurity
    $NewDirACL.SetOwner($Admin)
    $NewFileACL.SetOwner($Admin)
    if( Test-Path $Path -PathType Container ) {
    $Folder = Get-Item $Path -Force
    $Folder.SetAccessControl($NewDirACL)
    } elseif( Test-Path $Path -PathType Leaf ) {
    $File = Get-Item $Path -Force
    $File.SetAccessControl($NewFileACL)
    } else {
    Write-Host -ForegroundColor Red -BackgroundColor Black "ERROR: Path does not exist: $Path"
    } # End of Process {}
    End { } # End of End {}
    } # End of Function Take-Ownership
    Find this post helpful? Does this post answer your question? Be sure to mark it appropriately to help others find answers to their searches.

  • FTP a file to given mailbox loacted at ip-address and port number

    I need technical suggestion on the following.
    Actually I got struck up with a technical issue related to FTP a file to UNIX mailbox through ABAP.
    We have tried with FM: SXPG_CALL_SYSTEM and FTP_CONNECT, which all works purely based on IP, USER ID and PWD.
    But we have an extra PORT NUMBER, which any of this FM doesnu2019t take up.
    Can you please suggest me any other FM that I can use to FTP a file to specified IP with Port Number along with User id and PWD.
    Else are we supposed to go for a separate script for this purpose?
    As i have no clue on UNIX, if i go for a script than what would be the reuirement for this script and where to place them and how to call them in to my ABAP?
    Timely help would be appreciable.
    Thanks in advance
    Edited by: yamuna pillai on Nov 11, 2008 8:37 AM

    Hi Yamuna,
    Can you let us know hw u did this..because we are facing the same kind of issue.
    Thanks
    Gayathri

Maybe you are looking for

  • Zooming an image and scrolling it using a JScrollPane

    Hi all, I know this is one of the most common problems in this forum but i cant get any of the replys to work in my code. The problem: I create an image with varying pixel colors depending on the value obtained from an AbstractTableModel and display

  • Outbound Order Confirmation - Output control for incomplete sales orders

    Hi EDI Folks, I have a simple question. I want to send EDI 855 for only the completed sales orders. Whenever inbound sales order is processed and if the order is incomplete. I don't want to send the order confirmation for the order at that point of t

  • Outlook 2011 for Mac. Archive problem.

    VIP user has Outlook 2011 for Mac. Not deleted from the Exchange 2007 server leaves when archived. Mac OS X "Mail" client, this function works well, but right now some Inbox empty its contents.I would like to get an answer to the problem archiving...

  • There is NO PICTURE

    I can hear the sound but i cannot see the picture its just black It doesn't work when I tried to fix it. In Verizon box, there is a red light on "relplacing batteries'  I am not sure but I think that is the reason

  • 4710 in one-armed mode

    is it possible to preserve the clients originating IP address somewhere while using the 4710 in one armed mode?  I have a situation where the client source ip is needed, and I am deciding between one-armed mode and inline.  I'd like to use one-armed,