C# 检查用户是否为组成员(ldap)

C# 检查用户是否为组成员(ldap),c#,windows-mobile,ldap,compact-framework,C#,Windows Mobile,Ldap,Compact Framework,我想检查用户是否是c#中某个组的成员。该应用程序正在windows mobile 6.1上运行,我必须将ldap功能与[DllImport]一起使用 有人有这个的样品吗? 连接到ldap服务器并检查用户/密码是否有效。为什么不使用框架中已有的内容 看看这个: 或 如果使用C#/VB.Net和System.DirectoryServices,则此代码段应能实现以下功能: DirectoryEntry rootEntry = new DirectoryEntry("LDAP://dc=yourcom

我想检查用户是否是c#中某个组的成员。该应用程序正在windows mobile 6.1上运行,我必须将ldap功能与
[DllImport]
一起使用

有人有这个的样品吗?
连接到ldap服务器并检查用户/密码是否有效。

为什么不使用框架中已有的内容

看看这个:

如果使用C#/VB.Net和System.DirectoryServices,则此代码段应能实现以下功能:

DirectoryEntry rootEntry = new DirectoryEntry("LDAP://dc=yourcompany,dc=com");

DirectorySearcher srch = new DirectorySearcher(rootEntry);
srch.SearchScope = SearchScope.Subtree;

srch.Filter = "(&(objectClass=user)(sAMAccountName=yourusername)(memberof=CN=yourgroup,OU=yourOU,DC=yourcompany,DC=com))";

SearchResultCollection res = srch.FindAll();

if(res == null || res.Count <= 0)
    Console.WriteLine("This user is NOT a member of this group");
else
    Console.WriteLine("This user is INDEED a member of this group");
DirectoryEntry rootEntry=newdirectoryEntry(“LDAP://dc=yourcompany,dc=com”);
DirectorySearcher srch=新的DirectorySearcher(rootEntry);
srch.SearchScope=SearchScope.Subtree;
srch.Filter=“(&(objectClass=user)(sAMAccountName=yourusername)(memberof=CN=yourgroup,OU=yourOU,DC=yourcompany,DC=com));
SearchResultCollection res=srch.FindAll();

if(res==null | | res.Count)这个问题是关于紧凑型框架的(我在标签中已经阐明),它不支持
WindowsPrincipal
DirectoryEntry
DirectoryEntry rootEntry = new DirectoryEntry("LDAP://dc=yourcompany,dc=com");

DirectorySearcher srch = new DirectorySearcher(rootEntry);
srch.SearchScope = SearchScope.Subtree;

srch.Filter = "(&(objectClass=user)(sAMAccountName=yourusername)(memberof=CN=yourgroup,OU=yourOU,DC=yourcompany,DC=com))";

SearchResultCollection res = srch.FindAll();

if(res == null || res.Count <= 0)
    Console.WriteLine("This user is NOT a member of this group");
else
    Console.WriteLine("This user is INDEED a member of this group");