惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
U
Unit 42
腾讯CDC
D
Docker
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
I
InfoQ
Jina AI
Jina AI
爱范儿
爱范儿
宝玉的分享
宝玉的分享
博客园 - Franky
G
Google Developers Blog
P
Proofpoint News Feed

博客园 - 玄新

asp.net 2.0 中加密web.config 文件中的配置节 Windows DNA架构 如何使用 Visual C# .NET 检查 Windows 版本[转] 使用WMI来获取CPU序列号 - 玄新 - 博客园 什么是WMI C#读取设备信息(源代码下载) 格式化日期型数据 用 javascript显示时间日期代码(来自网上) - 玄新 - 博客园 昨天发现System.Diagnostics.Process 一样的可以打开一个网页的,直接的输入网页的地址就好了 - 玄新 - 博客园 文本框输入限制大全 在b/s开发中经常用到的javaScript技术 文本框里只能输入数字和退格键 (datagridview)如果单击列表头,全选.(第一列为复选框) DataGridView新特色(vs2005) 实现窗体淡入淡出的完整代码 excel 导入导出access数据库(winform) 递归得到叶子节点。 验证手机号码,小灵通号码函数 如何在SQL中对行进行动态编号
使用DirectoryServices给文件添加访问权限 - 玄新 - 博客园
玄新 · 2007-01-30 · via 博客园 - 玄新

using System;
using System.Collections;
using ActiveDs;

namespace PardesiServices.FixFilePermission
{
  class FileSecurity
  {
    [STAThread]
    static void Main(string[] args)
    {
        string strFile = @"D:\mmcInst.log";
        try
        {
            ADsSecurityUtilityClass secuUtil = new ADsSecurityUtilityClass();
            object ob = secuUtil.GetSecurityDescriptor(
                strFile,
                (int)ActiveDs.ADS_PATHTYPE_ENUM.ADS_PATH_FILE,
                (int)ActiveDs.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
            if (null != ob)
            {
                ActiveDs.IADsSecurityDescriptor sd =
                  (IADsSecurityDescriptor)ob;
                ActiveDs.IADsAccessControlList obDacl =
                 (ActiveDs.IADsAccessControlList)sd.DiscretionaryAcl;
                bool bAddAce = true;
                IEnumerator obAceEnum = obDacl.GetEnumerator();
                while (obAceEnum.MoveNext())
                {
                    IADsAccessControlEntry obAce =
                     (IADsAccessControlEntry)obAceEnum.Current;
                    Console.WriteLine("Trustee: {0}", obAce.Trustee);
                   
                    if (obAce.Trustee.IndexOf("ASPNET") != -1)
                    {
                       
                        if (obAce.AceType ==
                          (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED)
                        {
                            bAddAce = false;
                        }
                    }
                }

               
                if (bAddAce)
                {
                    AccessControlEntryClass obNewAce =
                      new AccessControlEntryClass();
                    obNewAce.AceType =
                      (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED;
                    obNewAce.Trustee = @"ASPNET";
                    obNewAce.AccessMask = -1;
                    obDacl.AddAce(obNewAce);
                    sd.DiscretionaryAcl = obDacl;
                    secuUtil.SetSecurityDescriptor(
                            strFile,
                            (int)ADS_PATHTYPE_ENUM.ADS_PATH_FILE,
                            sd,
                            (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}