C# LDAP路径和查询本地用户目录的权限?
我正在开发一个web应用程序,ASP.NET,C#。用户需要使用帐户local登录到运行应用程序的机器,在本例中,我称之为“cyclops”。我希望应用程序能够查询用户和组的本地目录,以确定用户所在的组。代码如下所示:C# LDAP路径和查询本地用户目录的权限?,c#,asp.net,permissions,active-directory,C#,Asp.net,Permissions,Active Directory,我正在开发一个web应用程序,ASP.NET,C#。用户需要使用帐户local登录到运行应用程序的机器,在本例中,我称之为“cyclops”。我希望应用程序能够查询用户和组的本地目录,以确定用户所在的组。代码如下所示: DirectoryEntry entry = new DirectoryEntry("WinNT://cyclops/Users", "SomeServiceAccount", "SvcAcctP@$$word", AuthenticationTypes.Secure);
DirectoryEntry entry = new DirectoryEntry("WinNT://cyclops/Users", "SomeServiceAccount",
"SvcAcctP@$$word", AuthenticationTypes.Secure);
entry.RefreshCache();
// Etc.
我的两个问题是:
-JWWinNT需要以下格式
WinNT://<domain/server>/<object name>,<object class>
在哪里
- UserAccount是所需用户的名称李>
- 点代表当前机器(您可以用cyclops或use Environment.MachineName替换它)
- 可能需要用户凭据(“SomeServiceAccount”、“SvcAcctP@$$word”),具体取决于设置
using (DirectoryEntry entry = new DirectoryEntry("WinNT://./Users,group"))
{
foreach (object member in (IEnumerable)entry.Invoke("Members"))
{
using(DirectoryEntry m = new DirectoryEntry(member))
{
Response.Write(m.Name);
}
}
}
在哪里
- Users是组的名称
using (DirectoryEntry entry = new DirectoryEntry("WinNT://./Users,group"))
{
foreach (object member in (IEnumerable)entry.Invoke("Members"))
{
using(DirectoryEntry m = new DirectoryEntry(member))
{
Response.Write(m.Name);
}
}
}