Delphi-与ADSI合作-如何检索所有组成员 [英] Delphi- working with ADSI- how to retrieve all group members

查看:89
本文介绍了Delphi-与ADSI合作-如何检索所有组成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Active Directory服务接口并尝试检索组中的所有用户.我有这行代码,这使我自己成为小组成员:

I`m working with Active Directory service interfaces and trying to retrieve all users out of a group. I have this line of code which brings me the group itself:

var
  Group:IADSGroup;
begin
  ADsGetObject('LDAP://CN=myGroup,CN=Users,DC=dltomb,DC=dltomb25,DC=com', IADSGroup, Group);
......

IADSGroup接口具有一个"IsMember"函数,该函数获取代表用户的WideString,如果用户是该组的成员,则应返回true.问题是我总是从这个答案中得到否定的答案...(我正在检查的用户是该组的唯一用户,并且还检查了Group.Count以查看该组中是否有一个成员).即使在有人可以指出其他变通办法(例如枚举组成员)的情况下,如果真的希望得到有关此问题的帮助(我也无法做到这一点)

the IADSGroup interface has a "IsMember" function that gets a WideString representing a user, and should return true if the user is a member of this group. the problem is that i always get a negative answer from this one... (the user i`m checking is the only user of this group and also checked Group.Count to see that there is one member in this group). if would really like some help regarding this issue, even if someone can point on other workaround such as enumerating the group members (I couldn't do this also)

推荐答案

好,我发现了如何迭代组

ok I Found how to iterate the group

var
  groupName: string;
  Fetched: Cardinal;
  ResultItem: OleVariant;
  members: IADsMembers;
..............
groupName:= Group.get_Name;
members:= Group.Members;
enum:= members._NewEnum as IEnumVariant;
Enum.Reset;

Enum.Next(1, ResultItem, Fetched);

while Fetched = 1 do
begin
  GroupMember := IDispatch(ResultItem) as IADS;
  //do something
  Enum.Next(1, ResultItem, Fetched);
end;

但是我现在遇到另一个问题,添加其他成员时看不到该组的所有成员.我之所以这样说是因为,由于某种原因,它发现只有用户属于该组,并且该组也不是其主要组.我如何也可以将正在搜索的组作为其主要组的用户?

But i have another problem now, i can't see all members of the group when adding other members. i red that this is because for some reason it finds only users belong to this group and also that this group is not their primary group. how can i get also a users with the group I`m searching as their primary group?

这篇关于Delphi-与ADSI合作-如何检索所有组成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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