使用C#枚举Windows用户组成员远程系统上 [英] Enumerate Windows user group members on remote system using c#

查看:693
本文介绍了使用C#枚举Windows用户组成员远程系统上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,我需要能够


  • 连接到远程系统,指定的用户名/密码,适当

  • 列出一个本地组的成员在该系统上

  • 结果取回执行的计算机

例如,我将连接适当creds到\SOMESYSTEM,并获取回本地管理员包括SOMESYSTEM\Administrator,SOMESYSTEM\Bob,DOMAIN\AlanH的名单,DOMAIN\域管理员。

So for example I would connect to \SOMESYSTEM with appropriate creds, and fetch back a list of local administrators including SOMESYSTEM\Administrator, SOMESYSTEM\Bob, DOMAIN\AlanH, "DOMAIN\Domain Administrators".

我已经试过这与system.directoryservices.accountmanagement但正在运行与身份验证问题。有时我:

I've tried this with system.directoryservices.accountmanagement but am running into problems with authentication. Sometimes I get:

到服务器或共享资源由同一用户使用多个用户名多个连接,是不允许的。断开与服务器或共享资源的所有连接,然后再试一次。 (从HRESULT异常:0x800704C3)。

以上是尝试,因为会有情况下我根本无法取消映射现有的驱动器或UNC连接

The above is trying because there will be situations where I simply cannot unmap existing drives or UNC connections.

其他时候我的程序获取未知错误和远程系统上的安全日志报告错误675,代码的0x19这是KDC的 ERR 的PREAUTH_REQUIRED。

Other times my program gets UNKNOWN ERROR and the security log on the remote system reports an error 675, code 0x19 which is KDCERRPREAUTH_REQUIRED.

我需要一个更简单且不易出错的方式来做到这一点!

I need a simpler and less error prone way to do this!

推荐答案

这应该很容易使用WMI的事情。在这里,您有一个指向某个文档:

This should be easy to do using WMI. Here you have a pointer to some docs:

WMI的文档Win32_UserAccount

即使你有没有WMI以往的经验,应该是很容易打开,在VB Script代码页面进入一些.NET代码的底部。

Even if you have no previous experience with WMI, it should be quite easy to turn that VB Script code at the bottom of the page into some .NET code.

希望这有助于!

这篇关于使用C#枚举Windows用户组成员远程系统上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆