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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - vibration

ATL3.0组件注册bug的解决方法 奇怪的引用错误及解决方法 OLE2T在VS2003中转换中文失败的问题及解决方法 标题栏按钮的WTL实现 AppBar的WTL实现 招聘C++和C#开发工程师 ATL组件中文路径注册问题(转载) 关于C++模板的连接问题 - vibration - 博客园 用窗口消息解决COM接口的多线程访问问题 用全局接口表实现COM接口在不同线程中的传递 MyMSN支持自定义内容了 自画菜单的WM_MEASUREITEM只会发送一次 悼念皮皮 上了点照片 一个测试记忆力的小游戏 老板该如何向核心员工许诺 ActiveScript SkinX界面换肤框架更新 Skin技术实现框架(完)
反射获取定制Attribute
vibration · 2004-06-01 · via 博客园 - vibration

前段时间写了扩展.net安全机制(1, 2),当时做了些试验代码,关于用户权限控制的功能是没有问题的,但关于权限管理却没有做实际的代码进行试验。当时想当然的认为可以通过反射机制读取到定制安全属性的内容,这几天开始做实际的代码,却发现并没有这么简单
我的目标是这样的,打开一个dll文件,通过反射得到其所有类和方法,并调用GetCustomAttributes方法获取其Attribute,然后读取这些Attribute记录的数据并入库管理。可是,现在发现GetCustomAttributes方法好像不能得到从CodeAccessSecurityAttribute继承的属性。我尝试了自己定义的安全Attribute和.net提供的PrincipalPermissionAttribute,都不行。用.NET Reflector看了一下反编译后的代码,发现这些Attribute变成了PermissionSetAttribute。可是,既然Reflector可以看到PermissionSetAttribute,那么我自己的代码通过反射应该至少也可以看到这个啊,看来还需要继续研究
不过,就目前情况,也有个不太完美的解决方案,就是除了安全Attribute,再定义一个普通的定制Attribute,记录需要管理的信息,这个普通的Attribute是可以通过GetCustomAttributes得到的,这个我已经试验过。这个方案不完美的地方就是要为需要安全控制的对象加两个Attribute,而且要保证其内容一致。确实不完美,不过可以用,也许只能采用这个方案了

posted on 2004-06-01 11:38  vibration  阅读(1831)  评论()    收藏  举报