PS script that fills security zones in IE

This script fills the IE security zones. The idea is for it to be added as a logon script. I reworked it from the original script from David Wyatt on https://social.technet.microsoft.com/Forums/windowsserver/en-US/84434209-0b35-49f1-91f7-0e041ca656da/powershell-add-url-to-intranet-zone?forum=winserverpowershell
The script was tested on PowerShell 4.0.
Each IE security zone has an array of domains.
It goes like this :
#Script for adding domains to diferent zones
#Define zone arrays and zone values
$LocalArray=@("firstlocal.com", "secondlocal.com")
$TrustedArray=@("firsttrusted.com", "secondtrusted.com")
$RestrictedArray=@("firstrestricted.com", "secondrestricted.com")
$LocalValue=(1)
$TrustedValue=(2)
$RestrictedValue=(4)
#Add array elements to Local intranet zone
ForEach ($element in $LocalArray)
#Add to Domains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $LocalValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $LocalValue -Type DWord
#Add to EscDomains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $LocalValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $LocalValue -Type DWord
#Add array elements to Trusted intranet zone
ForEach ($element in $TrustedArray)
#Add to Domains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $TrustedValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $TrustedValue -Type DWord
#Add to EscDomains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $TrustedValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $TrustedValue -Type DWord
#Add array elements to Restricted intranet zone
ForEach ($element in $RestrictedArray)
#Add to Domains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $RestrictedValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $RestrictedValue -Type DWord
#Add to EscDomains
$Path=("HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\" + $element)
if (-not (Test-Path -Path $Path))
New-Item -Path $Path
Set-ItemProperty -Path $Path -Name http -Value $RestrictedValue -Type DWord
Set-ItemProperty -Path $Path -Name https -Value $RestrictedValue -Type DWord
The script is ugly and long. It repeats for each of the three zones.
Any idea how to add a second loop that would shorten it?
Newb

Your request doesn't make any sense.  You have three sets of unrelated things.  You need three loops.
¯\_(ツ)_/¯

Similar Messages

  • Auto-Fill Secure Zone Members' Information to a webform?

    Hi, everyone:
    I'm working with webforms in a secure zone and the system is insisting on having users enter their information - name & e-mail address.  Since they've already provided this information when registering for the secure zone, I'd prefer to use a {module_firstname} etc. insert for their information rather than ask them to type it repeatedly.  I've tried removing the input fields and replacing them with the tags, but this results in an error message.  Is there any way to do this?
    Thanks!
    Linda

    Hi Linda,
    If customer is logged into a secure, the data can be pulled from the customer's info and can be populated in the form fields. Please refer to the following article : http://kb.worldsecuresystems.com/924/cpsid_92481.html
    The above mentioned article has the steps to achieve this. If you still face the problem, please reply with the exact error message you get and your site's URL.
    You can also contact support directly via Chat from http://helpx.adobe.com/contact.html and select Business catalyst from the dropdpwn or log a ticket.
    Cheers,
    Aishvarya Raj Rastogi

  • Secure Zone Issue

    First of all it is a kind of a nice idea and it seems to work quite well. However, if you put some apps in the secure zone, and deactive it in the open zone, you can still reactivate it in the open zone. That is you cant hide the existance of certane apps, only the date in them. Is that correct? Say you have a secret bank account with bank XYZ and you want to hide that you are using XYZ internet banking app from the open zone, or you want to hide your dating apps from your friends or family - you can't really do this with the current implementation, if I am right.  P.S: I get it, that the date will stay secure and protected, but you can not completely hide your ussage of some apps from the oppen zone. Finally, question if you have a virus or malware in the Open Zone, in theory this should not impact your secure zone? If the infected apps are deactivated? 

    Thanks again, huangzg, for the prompt and professional reply. I am also quite impressed and excited that you looked at my suggestions and considered to implement some of them.  Regarding the remaining open issues, I will repy in blue:
    4. Error when installing apps in SZ
    This should be an issue, we need more details to fix it. Please help to provide, thanks. When I tested the Vibe Z2 Pro, I was not able to install apps in the Secure Zone, via the Play Store (or any other way). When in SZ, I opened Google Play Store, I found an app, I clicked install, and the Google Playstore started installing, after it interrupted and gave me an error message, like there is a bug.  I do not remember the exact error message, but I can provide it if necessary. It was only possible to install apps in the Open Zone. Some other users confirmed that this is the case.  Franky, I do not think this is a problem as the Open Zone is a sort of administration zone where all the apps are installed. So I thought this is a functionality , that it is not possible to install apps in the Secure Zone. That is fine and I do  think it is probably increasing the security of the SZ. However, what bothers me from user perspective, is that the google play store gives error message like as if there was a bug.  Which might confuse users. Although, this is not a bug only a functionality. So I suggested, that instead of getting an error message when installing apps in playstore via the SZ, the SZ could give a message something like "All new apps have to be installed in the Open Zone". Having that said, I do not know if this is possible to implement, as the error message comes form the google play store, so I do not know if you can actually catch the play-store error message or pressing of the install button and replace it with secure zone message. It is just cosmetics. 6. It is a great secure zone but not a guest zone
    Guest mode is coming in Google Android L version. Any devices upgraded to Android L will include this feature. What kind of guest mode will this be? Will it be basically a second secure zone that will be labeled guest mode? Will it only have 1 extra guest mode or several? I am not trying to push the limits, I am just being curious.  P.S. I also think a guest mode could be used as an personal user mode. I could put all the apps that I use daily in the "user mode / guesst mode" and thus the Open Zone would serve only as an admin zone for installing apps. Or think of it as a glorified app drawer. I.e. it would be possible under some conditions to use the guest mode as your own user account with just selected enabled apps. That would go a bit beyond anything that currently exists by other developers. Thus, it is just brainstorming, not a suggestion.  Above changes will be available in K920 ROW L version. I am now testing the Vibe Z2 (5.5 inch, 2 GB RAM). I did not find the secure zone there. Should I assume that the secure zone will only be available on the Vibe Z2 Pro also after the L update? Does this has to do anything with the 3GB of RAM in the Pro version? Vibe X2 and Vibe Z2 have 2GB RAM, is that too little to roll out a secure zone on those phones?

  • Secure Zone Help Needed

    I want to add a secure zone to my website so I can create a members-only section to the website. I created it in Adobe Muse and am hosting it through Adobe Catalyst. I am trying to follow the instructions provided here: http://kb.worldsecuresystems.com/kb/add-secure-area-your-site.html . However, I do not have a link in my Site Manager that says "Secure Zone" like the instructions say I should. The only two links in this area are "Web Forms" and "System Email". I have the webBasics account. Do I need to upgrade to have a Secure Zone?

    Breakdown of the plans you get:
    http://helpx.adobe.com/business-catalyst/kb/detailed-plan-breakdown.html#id_52372

  • What level of support is required for Secure Zones?

    I am trying to determine the most cost effective hosting solution for a potential client.  They will have a very basic website, but they want a secure area for downloading project information. 
    What is the lowest cost hosting package that will support secure zones?  (i.e. WebBasics+)

    Hi,
    Lowest plan that provides secure zone access would be "webMarketing". 
    To view feature breakdown per plan please view the page below.
    - http://helpx.adobe.com/business-catalyst/kb/detailed-plan-breakdown.html
    Hope this helps!
    -Sidney

  • Secure zone - ERROR: The payment gateway that you are using does not support recurring payments

    So I want to sell a product that is made up of 4 downloadable products. (Totalling ~ 200meg)
    The only way I have found is to sell membership to a secure area where the files are linked.
    When I create the secure zone, I want a one-time-fee, but the system says:
    "ERROR: The payment gateway that you are using does not support recurring payments"
    The payment isn't recurring!
    Micah

    "Note that you have to use seamless gateway to process such payments."
    Right, but that's the problem, we're not usiong a seamless gateway and thus we get the error.  Again, the system should note that we're doing a one-time charge and not throw the seamless gateway error.
    Micah

  • Looking for jquery lightbox script that stretches image to fill viewport

    There are a lot of lightbox scripts out there, but most of them seem to favor static-sized images.
    I'm surprised that I haven't been able to find too many of these scripts allow for images to make maximum use of a viewport's dimensions. In other words, lightbox-style scripts that will fit the target image inside the viewport (while retaining the image's native proportions), whatever size said viewport may be.
    I can easily imagine everyone from graphic designers, to painters, to photographers jumping on such a tool. After all, there's nothing worse than looking at a 500px image on a 1920px display. It makes the work feel small, and by proxy, the work's author look small.
    Granted, for the images to not appear stretched, the native size of the image would have to be larger than needed for most visitors, but portfolio websites aren't high-traffic websites. They're solely visited by potential employers and clients, and loading time isn't much of a concern anymore with today's average home broadband speeds topping 1mb/s.
    Ideally, the script would grey-out the website, and display an image to match 95% of the viewport's X or Y resolution (whatever is smallest) while retaining the image's native proportions.
    Does anyone know where I can find such a script, preferable in jquery (since I'm already using it on my website)?

    Finally found one! -> http://www.shadowbox-js.com
    I've been testing it out, and it does exactly what I described above. It's great.

  • How do I redirect a secure zone login form with javascript?

    I would like to redirect what page a user goes to after filling out the secure log in form. I would change the landing page of the secure zone, but I need a log in form to go to a different page of the site. I would also create a seperate secure zone, but I have almost 3000 subscribers and it would be very time consuming to add all those users to this new zone.
    I would like to redirect the user (using the form from a secure zone) to a different page other than the landing page of the log in form. How do I do this with javascript?
    I saw this page: http://kb.worldsecuresystems.com/598/bc_598.html#main_Logging_into_different_Secure_Zones_ according_to_ID_number but couldn't make sense of it for my current situation. (I don't need multiple zones, just the form to redirect to a different page after submission)
    <form action="https://redlakewalleye.worldsecuresystems.com/ZoneProcess.aspx?ZoneID=12369&Referrer={module_siteUrl,true,true}&amp;OID={module_oid}&amp;OTYPE={module_otype}" method="post" onSubmit="return checkWholeForm52938(this)" name="catseczoneform52938">
                <div class="form">
                <div class="item"><label for="SZUsername">Username</label><br />
                <input type="text" maxlength="255" id="SZUsername" name="Username" class="cat_textbox_small" /></div>
                <div class="item"><label for="SZPassword">Password</label><br />
                <input type="password" autocomplete="off" maxlength="255" id="SZPassword" name="Password" class="cat_textbox_small" /></div>
                <div class="item"><input type="checkbox" id="RememberMe" name="RememberMe" /><label for="RememberMe">Remember Me</label></div>
                <div class="item"><input type="submit" value="Log in" class="cat_button" /> <a href="/_System/SystemPages/PasswordRetrieveRequest">Lost password?</a></div>
                </div>
                <script type="text/javascript" src="/CatalystScripts/ValidationFunctions.js"></script>
                <script type="text/javascript">
                    //<![CDATA[
                    function checkWholeForm52938(theForm){
                        var why = "";
                            if (theForm.Username) why += isEmpty(theForm.Username.value, "Username");
                            if (theForm.Password) why += isEmpty(theForm.Password.value, "Password");
                            if (why != ""){alert(why);
                                return false;
                       // Add the redirect code here?
                        theForm.submit();
                        return false;
                    //]]>
                </script>
            </form>

    I've been working on the same thing and have nearly solved it with these tutorials:
    http://www.bcgurus.com/tutorials/re-directing-users-to-the-correct-secure-zone
    http://www.bcgurus.com/tutorials/building-a-better-secure-zone-login-page
    The first tutorial will let a person continue on to the page he/she was attempting to access. For example, if your site offers learning lessons in a secure zone... A visitor could click on a lesson, get prompted to login and then be redirected to that particular lesson instead of the landing page for the secure zone.  The script in the tutorial also accommodates general logging in: "if the person wasn't going somewhere specific then send him/her here (landing page, user account, whatever).
    Might be worth checking out the free BCGurus trial or joining for a month.
    Brian

  • Single form for secure zone registration and web app submission?

    Hi
    Is it possible to setup a form where a user can simultaneously register for a secure zone and submit a web app entry? The knowledge base / tutorials describe a two step process (web form for secure zone registration and web app input form for web app submission), but I would like users to be able to do both with a single form
    Thanks in advance for any suggestions
    mls

    In order to have a customer create a web app item they must be logged into the secure zone already.  I've seen some instructions on how to let users submit web app items outside a secure zone but that requires creating a dummy anonymous user and logging them into the secure zone via javascript.  You could use this method and once it's submitted you'll have to manually attach the web app item to the correct user in the BC Admin.  That might not work for you but you can read more about that at http://forums.adobe.com/docs/DOC-1784
    You can't use the above solution with the current user's username and password because those tags are only available when the user is logged into a secure zone already.  If your signup form needs to be filled out first, the user isn't logged in.
    Your best bet is to have the public signup form redirect the user after submission to an "Add item" form you have created. Maks sure that form is in a secure zone so when they add the item it is attached to their account.
    If you don't want to redirect them to a secure zone and want it more seamless you could try to use some javascript/ajax to submit the form via javascript and after the form is submitted, use the javascript code in the above to log them in (be careful to use the https://yoursite.worldsecuresystems.com url if you are passing username and password info gathered from your form to log them in via javascript/ajax).  Once they are logged in via the javascript you can use more ajax to fetch a page's HTML that resides in a secure zone.  This HTML returned from the javascript can be your "add web app item" form and since they were logged in via javascript (securely, right?) this HTML should contain the right information.  Insert this returned HTML into your form container that held the original signup form and they can continue to add a web app item without having to log in.
    This is theory and might work but you'll have to start experimenting with it via javascript.  I haven't actually tried to do this so hopefully some other community members who might have tried this can weigh in here as well.
    Good luck!

  • Export Secure Zone Username Report

    Strangely enough, I just found that while I can export a report with contacts' usernames and I can export a report with contacts and their secure zones, I can't export a report with both secure zones and each contact's username.
    Can you help me work out how I could do it?
    Even a thought on how to combine the two csv files with a script?
    Thanks heaps,
    Joshua

    Hi Sidney,
    I have discovered further problems now that I have added the login and password fields to the webform.
    1. The webform did not update with the new fields when I went in to customise it. So I had to reset the form to original setup and lose all of the extra coding done on the form including:
    a. javascript to set an expiry date for access to the secure zone
    b. coding to the amount field so that it could not be changed
    c. Zip to postcode and Cell to mobile phone labels
    d. other fields marked as hidden
    Below are screen shots to show that I added the password and login fields but they were not in the webform when I went in to edit it.
    Not good.
    Also, the javascript checking on the required fields for the forms are not working.
    And finally, when testing the form and adding a username and password, the person was subscribed to the secure zone, but the welcome secure zone subscription email giving them the user name and password still did not trigger.
    and
    they were subscribed with a different username, not the one on the form.
    So bottom line, webforms seem to be a bit broken at the moment. Is that the case? I have given up on doing the secure zone subscription from the forms now, and will tell the client it can't be done at the moment.
    I still need to get the javascript checking working on the forms though, and remember submitting a question about that a while ago. Looks like it is still a problem.
    Here is the screen showing that I added the new fields to the form and saved it.
    Here is the web form editor screen - with the new fields not there!

  • Switching between https secure zone to http domain

    Hi,
    I'd like to know what the best way to link back to a non secure zone http domain from a secure https (worldsecuresystems.com) domain. I've seen a few articles on this subject and tried a few different approaches, but nothing that I've read/tried seems to work completely. I've tried using the full path by adding {module_defaulturl} to links e.g. <a href="{module_defaulturl}/contact.html">Contact</a> and I've tried adding a content holder e.g.<a href='/{module_contentholder name="_Template - Default Domain Host"}/about.html'>About</a>, where the host/path is added to the content holder. I've also tried using the full path hardcoded. All three approaches work for navigating between/from https to http domains, so far so good.
    However, whereas this full path approach works to enable linking within the website, the links no longer work within the Visual Editor (ICE). It appears the ICE will not work with full path links. Does anyone know of a way around this, or know of a better approach to setting up links between https and http domains? I'm thinking of using javascript to add the full path to links when the page loads whilst on a secure domain so that the script doesn't run in the ICE. But is there a better/simpler way?
    Regards, Mark.

    Thanks for the suggestion although getting to the solution requires a subscription to their service. But your suggestion helps because they mention achieving what I want with jquery, so I assume that's the accepted way to go about it. I've already implemented a solution with jquery, I was just trying to see if there was another 'more native' BC way. Cheers

  • Is there a way to make secure zone content unique for user?

    Hi, we have a client who wants to have a secure zone on their site which will allow them to upload images and notify the user, so that when they login they will see their particular images (in a gallery with lightbox etc) but other secure zone users cannot see their images, they will only see their own images.
    I am looking at a combination of secure zone/web app/image gallery functionaity but cannot work out if this is even feasible (without some had core scripting).
    Does anyone know how we can set this up?
    Cheers
    Cam

    Hi,
    You can do this via web-apps (placed inside a secure zone). A webapp can be customized to allow users to add and edit their submissions, can be integrated with google maps, can have expiry dates, can require payments, etc. Here's a complete reference: http://helpx.adobe.com/business-catalyst/topics/web-apps.html
    Kind Regards,
    Alex

  • IE Security Zones

    Hi,
    I need to check whether Javascript and Cookies are enabled on Internet Explorer browser or not. So, I am checking IE security zones as mentioned in the following URL(checking the values in Zones -3) from .net code.
    http://support.microsoft.com/kb/182569
    I am checking the values of following registry keys under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"
    registry from .net.
    1400 Scripting: Active scripting1A02 Allow persistent cookies that are stored on your computer #
    I want to know whether it is right approach or not.
    Please help me.

    Hi Nagarajukt,
    It is not recommended to change the Internet Security settings through registry.
    For scripting and cookies, if we want to check if they are enabled or not, we may follow the steps below:
    For Javascripts, please see:
    How to enable JavaScript in a web browser?
    For cookies management, please check: Delete and manage cookies
    The reference you found out is the place to go, if you would like to check the changes, you may make the change through the UI, and then check the registry values.
    If you want to change registry settings, please remember to backup first.
    How to back up and restore the registry in Windows
    Best regards
    Michael Shao
    TechNet Community Support

  • Set expiration dates for Secure Zone Memberships

    We run an online exercise company offering memberships with access to exercise videos so users can exercise online - we sell memberships by the week, month, or month to month memberships. We also sell a beginner courses. The site has been built in Adobe Muse, integrated with Business Catalyst.
    For the time-based memberships we have inserted a snippet of code in Business Catalyst that limits the amount of time members have access to the secure zone where we keep the videos - this is tied to the form members fill out when they purchase. The issue is that when the entire Muse site is republished or just the page with the form - the code disappears. So we have to go into each form and reinsert the code. This has been going on for quite some time. Below is most of the code we've been using - which we found in Business Catalyst Forum Section a couple years ago:
    function setExpiryDate( )
    var dat=new Date();
    dat.setDate(dat.getDate() + 8);
    var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec")
    var pretty = dat.getDate() + "-" + monthname[dat.getMonth()] + "-" + dat.getFullYear();
    document.getElementById("ExpiryDate").value = pretty;
    };setExpiryDate( );
    We are looking to 'permanently' anchor the code in the form.

    Hi
    If you are using BC secure zones then you can setup the expiry date from BC end only, regarding the code that you are using , I believe you are trying to use specific form for secure zone sign up and limiting the expiry date.
    Regarding form code being stripped off, are you submitting the form once from site front end and then also code is stripped off ?
    Please include site url in your response.
    Thanks,
    Sanjit

  • Speeding up a script that checks ACLs on every folder

    I have a script that is looking for a very specific level of NTFS access permissions, specifically a specific SDDL. I already know that SDDL and have checked to make sure that I can submit the SDDL as a test string and compare it against a get-acl SDDL.
    The problem is this takes a long time (about 4 minutes for 4300 folders) and I've been asked to search through a few hundred thousand folders. Here's the code I have so far:
    $folders = gci c:\foo -Directory -Recurse
    ForEach ($folder in $folders)
    $path = $folder.fullname
    $acl = get-acl $path
    if ($acl.sddl -eq "O:BAG:DUD:PARAI(A;OICI;FA;;;BA)") {write-host -ForegroundColor Red "$path has only admins"}}
    Obviously I'll want to output to something other than my screen, but essentially I'm looking for ideas to speed that up.
    [email protected]

    Go here and get the LongPath.zip file. Inside it should be a file named 'Microsoft.Experimental.IO.dll'. You can use that with the code below to get around the 248 character path limit, and it should
    be pretty fast, too. Just fill in the first few variables with the information you're looking for. Note that it is possible for a security descriptor's effective access to be identical to another one that has a different SDDL string (I don't think that will
    happen here, though, because of the use of the CommonSecurityDescriptor class).
    This creates a C# class that uses the LongPath methods to list files and folders, and it uses the GetNamedSecurityInfo() API call along with the paths to get the binary form of the security descriptors. The searching for the SDDL happens inside of a C# method,
    too, to try to speed things up. I'm not really a C# developer, so someone else could probably make this even faster. Please give it a shot, though, and let me know if it works for you:
    $ExperimentalIoPath = "C:\path\to\Microsoft.Experimental.IO.dll"
    $PathToSearch = "c:\path\to\search"
    $SddlToFind = "O:BAG:DUD:PARAI(A;OICI;FA;;;BA)"
    Add-Type -Path $ExperimentalIoPath
    Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    using System.Security.AccessControl;
    using System.Collections.Generic;
    using Microsoft.Experimental.IO;
    namespace HSG {
    public class Helper {
    // http://msdn.microsoft.com/en-us/library/windows/desktop/aa446645%28v=vs.85%29.aspx
    [DllImport("advapi32.dll", EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode)]
    internal static extern uint GetNamedSecurityInfo(
    string ObjectName,
    System.Security.AccessControl.ResourceType ObjectType,
    SecurityInformation SecurityInfo,
    out IntPtr pSidOwner,
    out IntPtr pSidGroup,
    out IntPtr pDacl,
    out IntPtr pSacl,
    out IntPtr pSecurityDescriptor
    [DllImport("advapi32.dll")]
    internal static extern Int32 GetSecurityDescriptorLength(
    IntPtr pSecurityDescriptor
    [DllImport("kernel32.dll", SetLastError=true)]
    internal static extern IntPtr LocalFree(
    IntPtr hMem
    [Flags]
    public enum SecurityInformation : uint {
    Owner = 0x00000001,
    Group = 0x00000002,
    Dacl = 0x00000004,
    Sacl = 0x00000008
    public static CommonSecurityDescriptor GetSecurityDescriptor(string path, System.Security.AccessControl.ResourceType objectType, SecurityInformation securityInformation, bool isContainer) {
    IntPtr pOwner, pGroup, pDacl, pSacl, pSecurityDescriptor;
    pOwner = pGroup = pDacl = pSacl = pSecurityDescriptor = IntPtr.Zero;
    uint exitCode;
    exitCode = GetNamedSecurityInfo(path, objectType, securityInformation, out pOwner, out pGroup, out pDacl, out pSacl, out pSecurityDescriptor);
    if (exitCode != 0) {
    throw new Exception((new System.ComponentModel.Win32Exception(Convert.ToInt32(exitCode))).Message);
    if (pSecurityDescriptor == IntPtr.Zero) {
    throw new Exception(String.Format("No security descriptor available for {0} object with path {1}", objectType, path));
    byte[] binarySd;
    try {
    int sdSize = GetSecurityDescriptorLength(pSecurityDescriptor);
    binarySd = new byte[sdSize];
    Marshal.Copy(pSecurityDescriptor, binarySd, 0, sdSize);
    catch(Exception e) {
    throw e;
    finally {
    if (LocalFree(pSecurityDescriptor) != IntPtr.Zero) {
    throw new Exception(String.Format("Error freeing memory for security descriptor at path {0}", path));
    return new CommonSecurityDescriptor(isContainer, false, binarySd, 0);
    public class LongPathFileSystemItem {
    public LongPathFileSystemItem(string path, bool isContainer) {
    this.Path = path;
    this.IsContainer = isContainer;
    public string Path { get; private set; }
    public bool IsContainer { get; private set; }
    public static List<LongPathFileSystemItem> GetChildItemLongPath(string path, bool recurse) {
    List<LongPathFileSystemItem> results = new List<LongPathFileSystemItem>();
    try {
    // Get directories
    foreach (string folderName in LongPathDirectory.EnumerateDirectories(path)) {
    if (recurse) {
    results.AddRange(GetChildItemLongPath(folderName, true));
    results.Add(new LongPathFileSystemItem(folderName, true));
    // Get files:
    foreach (string fileName in LongPathDirectory.EnumerateFiles(path)) {
    results.Add(new LongPathFileSystemItem(fileName, false));
    catch (Exception e) {
    // Not the best way to handle errors, but didn't want to terminate
    results.Add(new LongPathFileSystemItem(string.Format("Error enumerating FS objects for '{0}': {1}", path, e.Message), false));
    return results;
    public static List<string> GetFileSystemObjectsWithSpecificSddl(string path, string sddl, bool recurse) {
    List<string> results = new List<string>();
    string currentSddl;
    foreach (LongPathFileSystemItem childItem in GetChildItemLongPath(path, recurse)) {
    if (childItem.Path.StartsWith("Error")) {
    results.Add(childItem.Path);
    continue;
    try {
    currentSddl = GetSecurityDescriptor(
    string.Format(@"\\?\{0}", childItem.Path),
    ResourceType.FileObject,
    SecurityInformation.Owner | SecurityInformation.Group | SecurityInformation.Dacl,
    childItem.IsContainer
    ).GetSddlForm(AccessControlSections.All);
    catch (Exception e) {
    results.Add(string.Format("Error getting security descriptor for '{0}': {1}", childItem.Path, e.Message));
    continue;
    if (sddl == currentSddl) {
    results.Add(childItem.Path);
    return results;
    "@ -ReferencedAssemblies $ExperimentalIoPath
    function Search-Sddl {
    [OutputType([string])]
    [CmdletBinding()]
    param(
    [string] $Path,
    [string] $Sddl,
    [switch] $Recurse
    process {
    [HSG.Helper]::GetFileSystemObjectsWithSpecificSddl($Path, $SddlToFind, $Recurse) | ForEach-Object {
    if ($_ -match "^Error") { Write-Error $_ }
    else { $_ }
    #All of that is used to define the Search-Sddl function, which is used like this:
    Search-Sddl -Path $PathToSearch -Sddl $SddlToFind -Recurse

Maybe you are looking for

  • Web service as a data source in Crystal Reports 2008

    Post Author: jpdv CA Forum: Data Connectivity and SQL I've tried to setup a new report using a web service as a data source. Untill now, I have not been successful. I always get the same error: unable to log on to data source. Is there any sample tha

  • Regd import statement - -added new question here

    Hi , I have developed a standalone page .. n now trying to import that into database ... import C:\JDEV9i-03\jdevhome\jdev\myprojects\cisco\oracle\apps\per\workscape\webui\WorkscapeUI.xml -rootdir C:\JDEV9i-03\jdevhome\jdev\myprojects\ -userId 1 -use

  • SAPGUI JAVA 7.10 rev 3 (OSX 10.5.2): ALV reports freeze

    Dear All, I've tried to use rev 3 of sapgui for java for mac osx. I have serious issues with ALV reports that makes it unusable (rev 2 is ok so far). With big lists ALV freezes after showing about half of the first screen lines. Is anyone experiencin

  • Has anyone seen this problem with IAC iviews?

    No Service Name Specified Your request did not contain a service name. Please provide a service name as part of the URL. Example URL: http://.../scripts/wgate/CreateSO/! or... Session Already Terminated There is currently no session running that migh

  • How do i reset my sercurity questions

    Ive got a brand new Ipod 5 because i had a 4g ipod and got the ipod 4g  for christmas 2010 and had sercurity Questions  to set up but i have forgotten them and the only way to have £ apps is to use the 4g ipod but has now Been wiped because we are se