开发者

Authenticating against a remote server and domain (C#/3.5)

I have a .Net 3.5 service that runs on a stand-alone computer. The service queries the event logs of servers in multiple Active Directory domains. I would like to authenticate to these using managed code.

Currently, I authenticate either with p/invoke to WNetAddConnection2A or w开发者_如何学JAVAith processing out with a net use. For example, this works:

string user = "domain\\administrator";
string pass = "password";
string server = "server.domain.com";
string argument = String.Format("use \\\\{0}\\ipc$ /user:{1} {2}", server, user, pass);
System.Diagnostics.Process.Start("net.exe", argument);
System.Diagnostics.EventLog log = new EventLog("System", server);

Is there a way in the .Net 3.5 framework to authenticate and read the event log without having to proc out or call unmanaged code?


Have you seen the "System.Security.Principal.WindowsImpersonationContext" and the demo written in MSDN.

Way back, in the .NET 1.1 days, I had to write a windows service for validation of users in 2 windows domains, used LDAP - and WindowsImpersonation as fail-back.

As I remember I got insperation form CodeProject and Google :-S

/Erling Damsgaard DNS-IT ApS

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜