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

推荐订阅源

G
Google Developers Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
IT之家
IT之家
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Threatpost
Cyberwarzone
Cyberwarzone
AWS News Blog
AWS News Blog
博客园 - 司徒正美
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
S
Secure Thoughts
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hacker News: Ask HN
Hacker News: Ask HN
大猫的无限游戏
大猫的无限游戏
博客园_首页
S
Security @ Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
AI
AI
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
Project Zero
Project Zero
P
Proofpoint News Feed
T
Tor Project blog
P
Privacy International News Feed
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
月光博客
月光博客
Forbes - Security
Forbes - Security
量子位
I
Intezer
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
腾讯CDC
N
Netflix TechBlog - Medium
www.infosecurity-magazine.com
www.infosecurity-magazine.com
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - Rain@sz

C#多线程编程(转) 调用webservice类(转) webService动态编译(编译在内存中,不会有权限问题) 什么是AOP? (摘) 阿里巴巴信息抓取器 脏读、不可重复读和虚读。(数据库)摘 c#写Activex控件(.Net 2.0) sql server 2005分页存储过程和sql server 2000分页存储过程(摘) net的辅助工具 ajax基本函数--js Memento Pattern(备忘录模式) Interpreter Pattern(解释器模式) State Pattern(状态模式) Mediator Pattern(中介者模式) 动态调用Webservice(摘) 分页--页脚控件 RSS 标准 DP-還未添加 DP-职责链模式(Chain of Responsibility)
SPS中模拟登陆
Rain@sz · 2008-08-04 · via 博客园 - Rain@sz

using System.Security.Principal;
using System.Runtime.InteropServices;===========================================应用===================================================================
   WindowsImpersonationContext wic 
= null;
   
try
   {
    wic 
= CreateIdentity (Uid,Domain,Pwd).Impersonate();
    
    
/*do something*/
    
/*do something*/
   }
   
catch(Exception ex)
   {
   }
   
finally
   {
    
if(wic != null) wic.Undo();
   }
===============================================================================================================#region 虚拟管理员用户
  
public static WindowsIdentity CreateIdentity(string User, string Domain, string Password)
  {
   
// The Windows NT user token.
   IntPtr tokenHandle = new IntPtr(0);const int LOGON32_PROVIDER_DEFAULT = 0;
   
const int LOGON32_LOGON_NETWORK = 3;

   tokenHandle 

= IntPtr.Zero;// Call LogonUser to obtain a handle to an access token.
   bool returnValue = LogonUser(User, Domain, Password, 
    LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT,
    
ref tokenHandle);if (false == returnValue)
   {
    
int ret = Marshal.GetLastWin32Error();
    
throw new Exception("LogonUser failed with error code: " +  ret);
   }

   System.Diagnostics.Debug.WriteLine(

"Created user token: " + tokenHandle);//The WindowsIdentity class makes a new copy of the token.
   
//It also handles calling CloseHandle for the copy.
   WindowsIdentity id = new WindowsIdentity(tokenHandle);
   CloseHandle(tokenHandle);
   
return id;
  }
  [DllImport(
"advapi32.dll", SetLastError=true)]
  
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
   
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

  [DllImport(

"kernel32.dll", CharSet=CharSet.Auto)]
  
private extern static bool CloseHandle(IntPtr handle);#endregion 虚拟管理员用户