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

推荐订阅源

IT之家
IT之家
Project Zero
Project Zero
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
Jina AI
Jina AI
C
Check Point Blog
博客园_首页
The GitHub Blog
The GitHub Blog
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
A
Arctic Wolf
博客园 - 三生石上(FineUI控件)
P
Privacy International News Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Forbes - Security
Forbes - Security
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
T
Troy Hunt's Blog
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
Schneier on Security
Schneier on Security
K
Kaspersky official blog
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
Know Your Adversary
Know Your Adversary
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
P
Proofpoint News Feed
小众软件
小众软件
S
Securelist
T
Tor Project blog

博客园 - 大坏蛋

struts 2.1配置 腾讯,你是怎么知道我机器上装了360的 程序.NET Framework版本升级,重签名,重链接,批量签名工具 .NET 平台优秀控件及源代码介绍(一) 灯神 终于轻松下来了 Friend Assemblies(.NET FrameWork 2.0新特性) .NET Remoting的新特性-IpcChannel(.NET Framework 2.0) 我的GMAIL开始使用 关于委派的返回值 .NET Remoting中的事件处理(.NET Framework 2.0) 关于MyIE2中博客园页面自动跳转的问题回答 Thread.Abort终止一个线程 今天统计了一下我们项目的代码 Friend Assembly 忘记交手机费,招商银行的自助缴费不错! 六一快到了,祝所有小朋友节日快乐 COM+连接池的问题 系统消息框居然是可以复制的
如何扮演另一个帐号(C#实现)
大坏蛋 · 2004-10-27 · via 博客园 - 大坏蛋

Using directives

namespace Impersonal
{
    
class Program
    
{
        
测试代码

        [DllImport(
"advapi32.dll", SetLastError = true)]
        
public extern static bool LogonUser(String lpszUsername, String lpszDomain,
            String lpszPassword, 
int dwLogonType,
            
int dwLogonProvider, ref IntPtr phToken);

        [DllImport(
"kernel32.dll", CharSet = CharSet.Auto)]
        
public extern static bool CloseHandle(IntPtr handle);

        [DllImport(
"advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        
public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,
            
int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);

        
public delegate void ImpersonatedWork();
        
/// <summary>
        
/// 以指定用户的身份去做一件事情
        
/// </summary>
        
/// <param name="UserName"></param>
        
/// <param name="PWD"></param>
        
/// <param name="WhatToDo"></param>

        public static void ImpersonateAndDo(string UserName, string PWD, ImpersonatedWork WhatToDo)
        
{
            
扮演用户
            
以新用户身份调用
            
取消扮演
        }

    }

}

最近太忙,好久不来,贴段刚写的代码,希望大家还记得我.