【问题标题】:Why can I find OUs using 'new DirectoryEntry(guid)' but not Principle.FindByIdentity?为什么我可以使用“new DirectoryEntry(guid)”而不是 Principle.FindByIdentity 找到 OU?
【发布时间】:2018-07-23 16:48:52
【问题描述】:

我正在尝试在 .NET Core 2.1 中使用 DirectoryServices.AccountManagement 定位我们商店位置的用户帐户。

如果我只是使用 OU 的 guid 新建一个 DirectoryEntry,它可以将条目拉回没有问题。但是,一旦我尝试使用 AccountManagement 主体,它总是为商店的用户帐户返回 null。

每个商店位置也有一个通讯组,我可以使用Principal.FindByIdentity 找到那些人,而不是商店的实际用户帐户。

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, _domainName, _username, _password)) 
{
    // returns null
    var testOU = Principal.FindByIdentity(pc, IdentityType.Guid, store.ActiveDirectoryOU.ToString());

    // returns proper DirectoryEntry for store's User Account
    var testEntry = new DirectoryEntry("LDAP://<GUID=" + store.ActiveDirectoryOU + ">");

    // returns proper Principal for store's distribution group
    var testGroup = Principal.FindByIdentity(pc, store.ActiveDirectoryGroup.ToString());
}

是否有某种设置阻止DirectoryServices.AccountManagement 看到某些用户帐户?还是我犯了一些新手错误?

【问题讨论】:

  • 我认为(可能是错误的)Principal 类中没有内置任何东西来搜索父级的 GUID。

标签: c# asp.net-core active-directory


【解决方案1】:

您正在使用 Principal.FindByIdentity 而不是 UserPrincipal.FindByIdentity 来获取特定用户。有没有可能是这个问题?

this example

See also >

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多