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

推荐订阅源

T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
P
Privacy International News Feed
L
LINUX DO - 最新话题
博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
C
Cisco Blogs
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
罗磊的独立博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
A
About on SuperTechFans
G
GRAHAM CLULEY
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
D
DataBreaches.Net
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
I
InfoQ
T
The Exploit Database - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 叶小钗
Project Zero
Project Zero

博客园 - 大坏蛋

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)
        
{
            
扮演用户
            
以新用户身份调用
            
取消扮演
        }

    }

}

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