如何使用adsgetObject获取域中组中组的IADSGROUP对象?

发布于 2025-01-24 12:31:55 字数 4584 浏览 0 评论 0 原文

简短版本

如何获得组的 IADSGROUP stackoverflow \ itops 的接口?

长期

我试图获得 IADSGROUP 使用 adsgetObject 函数

我拥有的唯一信息:

  • groupName :eg itops
  • domainname :eg stackoverflow

该功能采用 ldap路径到对象:

HRESULT ADsGetObject(
  [in]  LPCWSTR lpszPathName,
  [in]  REFIID  riid,
  [out] VOID    **ppObject
);

真正的困难是在提出 group 的实际 ldap路径时。例如:

  • ldap:// stackoverflow/itops 失败 (“已指定了无效的DN语法”)
  • ldap:// cn = itops,dn = stackoverflow 失败 0x800720202020 (“发生操作错误发生了”)
  • ldap:// cn = itops,dc = stackoverflow < /code> 失败 0x8007202b (“从服务器返回转介”)

给出的问题

  • 组名称(例如“ itops”)
  • 域名(例如,stackoverflow) ”)

如何获得组的 iAdsGroup stackoverflow \ itops 的接口?

奖励阅读

  • msdn:
  • MSDN:
  • msdn: ldap
  • adspath a href =“ https://lealen.microsoft.com/en-us/windows/win32/win32/ad/binding-to-to-to-to-an-object-usish-a-sid-using-a-sid“ rel =“ nofollow noreferrer”>使用对象绑定到对象sid
  • msdn:获取域名的示例代码
  • serverfault:在域/树/树中获取广告组路径
  • ldap路径的适当语法
  • stackoverflow stackoverflow.com/questions/23808451/ldap-path-and-permissions-to-query-local-user-directory"> dilectory"> dldap路径和权限查询本地用户目录?
  • msdn: winnt adspath
  • //learn.microsoft.com/en-us/windows/win32/adsi/winnt-adspath winnt_ldap.htm“ rel =“ nofollow noreferrer”> winnt vs. ldap
  • msdn:glossary winnt “ Windows NT名称空间提供商,支持Windows NT SAM帐户数据库。 Winnt提供商也可以用于访问Active Directory,但它将其视为平坦的名称空间
  • 。 /adsgetObject.html“ rel =“ nofollow noreferrer”> c语言函数:adsgetObject示例代码
  • msdn:不支持的iAdsuser属性 (“要获得和/或修改这些属性,请使用ldap Provider”,使用ldap Provider”)
  • msdn: msdn: winnt自定义用户属性 (“ winnt提供商可为用户类提供以下自定义属性”)

Short Version

How do i get the IADsGroup interface of the group STACKOVERFLOW\ITOps?

Long Version

I am trying to get ahold of the IADsGroup interface for a group in the domain using the ADsGetObject function.

The only information i have:

  • GroupName: e.g. ITOps
  • DomainName: e.g. STACKOVERFLOW

The function takes an LDAP path to an object:

HRESULT ADsGetObject(
  [in]  LPCWSTR lpszPathName,
  [in]  REFIID  riid,
  [out] VOID    **ppObject
);

The real difficulty is in coming up with the actual LDAP path for a group in the domain. For example:

  • LDAP://STACKOVERFLOW/ITOps fails ("An invalid dn syntax has been specified")
  • LDAP://CN=ITOps,DN=STACKOVERFLOW fails 0x80072020 ("An operations error occurred")
  • LDAP://CN=ITOps,DC=STACKOVERFLOW fails 0x8007202B ("A referral was returned from the server")

The question

Given:

  • a group name (e.g. "ITOps")
  • a domain name (e.g. "STACKOVERFLOW")

How do i get the IADsGroup interface of the group STACKOVERFLOW\ITOps?

Bonus Reading

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的那么颓废 2025-01-31 12:31:56

如果您不知道域的 dn ,则可以通过 rootdse

If you don't know the dn of the domain then you can obtain it via rootDSE

唐婉 2025-01-31 12:31:55

AD中有几个唯一的标识符,并且不能以相同的方式使用它们,这使事情有些混乱。

这是该路径所需的文档(您已经链接到): ldap adspath

表明LDAP路径应该看起来像:

LDAP://HostName[:PortNumber][/DistinguishedName]

hostName portnumber and code> dickinedname 都是可选的,取决于关于您要做的事情。如果您需要绑定到特定对象(这是您要做的事情),则必须 DiscondundedName 是强制性的。

杰出的名称是对象的 descontedname 属性,这就是为什么卢克建议您使用AD Explorer浏览到目录中的对象并检查 DiscondundedName 的值属性。 DN是通用名称(CN),每个组织单元(OU)和域DNS名称(例如Stackoverflow.com)的串联分为每个域组件(DC)。看起来像这样:

CN=ITOps,OU=Groups,DC=stackoverflow,DC=com

格式 stackoverflow \ itops 是域的短名称(正式称为netbios名称),与对象的 samacCountName 属性结合使用。这种格式通常用于用户帐户进行认证,但不能在LDAP路径中使用。

如果您将此组硬编码为代码,则只需查找 DiscondundedName 并使用它。如果您将获得用户的 stackoverflow \ itops 格式,并且需要绑定到它,则可以:

  1. 使用 iadneametranslate ads_name_name_name_type_nt4 ads_name_type_1779 ,或
  2. 使用搜索过滤器(samacCountName = itops)在域上执行搜索。要在C ++中执行LDAP搜索,请参阅文档的 idirectorySearch 。您仍然必须提供搜索的LDAP路径,但是您只需提供域DNS名称(例如 ldap://stackoverflow.com )。这使您可以指定希望您返回的属性,因此您可以告诉它您需要 DiscondundedName 。或者,如果您与对象绑定的目的是读取其他属性,则可以指定这些属性并从搜索结果中读取这些属性,然后您可以跳过直接绑定到对象的下一步。

似乎您打算使用C ++,但您没有具体说明。您正在使用C ++吗?

There are several unique identifiers for objects in AD, and they can't all be used in the same way, which makes things a bit confusing.

This is documentation you need for that path (which you already linked to): LDAP ADsPath

That shows that the LDAP path should look like:

LDAP://HostName[:PortNumber][/DistinguishedName]

The HostName, PortNumber and DistinguishedName are all optional, depending on what you're trying to do. If you need to bind to a specific object - which is what you're trying to do - then the DistinguishedName is mandatory.

The distinguished name is the distinguishedName attribute of the object, which is why Luke suggested that you use AD Explorer to browse to the object in your directory and inspect the value of the distinguishedName attribute. The DN is a concatenation of the common name (CN), each organizational unit (OU) and the domain DNS name (e.g. stackoverflow.com) split into each of its domain components (DC). That will look something like this:

CN=ITOps,OU=Groups,DC=stackoverflow,DC=com

The format STACKOVERFLOW\ITOps is the domain's short name (officially called the NetBIOS name), combined with the sAMAccountName attribute of the object. This format is often used for authenticating with user accounts, but cannot be used in an LDAP path.

If you're hard coding this group into your code, then just look up the distinguishedName and use that. If you will be given the STACKOVERFLOW\ITOps format by the user and need to bind to it, then you can either:

  1. Use IADsNameTranslate to translate from ADS_NAME_TYPE_NT4 to ADS_NAME_TYPE_1779, or
  2. Perform a search on the domain using the search filter (sAMAccountName=ITOps). To perform an LDAP search in C++, see the documentation for IDirectorySearch. You still have to provide an LDAP path for the search, but you can just provide the domain DNS name (e.g. LDAP://stackoverflow.com). That allows you to specify which attributes it wants you to return, so you can tell it that you want the distinguishedName. Or if your purpose in binding to the object is to read some other attribute, then you can specify those attributes and read those attributes from the search result, and then you can skip the next step of binding directly to the object.

It seems like you plan to use C++, but you didn't specifically say that. Are you using C++?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文