如何从LDAP获取组织单位下的所有对象的列表?

时间:2018-07-09 22:42:21

标签: c# ldap directoryentry directorysearcher ou

如何获取LDAP组织单位内每个用户和/或组的列表?

我正在尝试使用LDAP查询我的c#服务器。我想获得所有通讯组列表的列表。我所有的通讯组列表都归为一个组织单位(OU),称为“一般通讯组”。如何在“常规发行” OU下获得所有成员的列表?

下面是我用来查询LDAP服务的代码,该服务未返回任何结果。

try
{
        DirectoryEntry objADAM = new DirectoryEntry("LDAP://my_domain.com", "user@my_domain.com", "password");

        DirectorySearcher objSearchADAM = new DirectorySearcher(objADAM);
        objSearchADAM.Filter = "(&(OU=General Distributions,DC=my_domain,DC=com)"; 
        objSearchADAM.SearchScope = SearchScope.Subtree;
        SearchResultCollection objSearchResults = objSearchADAM.FindAll();


        // Binding path. 
        List<string> result = new List<string>();

        if (objSearchResults.Count != 0)
        {
            foreach (SearchResult objResult in objSearchResults)
            {
                DirectoryEntry objGroupEntry = objResult.GetDirectoryEntry();
                result.Add(objGroupEntry.Name);
            }

            return result;
        }

        throw new Exception("No result found");
}
catch (Exception e)
{
        throw e;
}

1 个答案:

答案 0 :(得分:0)

我知道这个问题有点老了,但是答案很简单。将OU本身用作 // pass projection matrix to shader glm::mat4 projection = glm::perspective(glm::radians(camera.getZoom()), static_cast<float>(WIDTH) / static_cast<float>(HEIGHT), 0.1f, 10000.f); shaderProg.setMat4("projecton", projection); // camera view transformation glm::mat4 view = camera.getViewMatrix(); shaderProg.setMat4("view", view); here i have just 1 model its my white bg-texture glm::mat4 model = glm::translate(model, glm::vec3(0.f, 0.f, 0.f)); model = glm::rotate(model, glm::radians(0.f), glm::vec3(1.0f, 0.3f, 0.5f)); shaderProg.setMat4("model", model); 的{​​{1}}:

DirectoryEntry