• 列出域中所有用户的代码 dodo


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.DirectoryServices;

    namespace WebAppLDAP
    {
        
    public partial class _Default : System.Web.UI.Page
        
    {
            
    protected void Page_Load(object sender, EventArgs e)
            
    {
                
    //ListAllUser();
                 showUser();
             }

            
    protected void showUser()
            
    {
                 DirectoryEntry entry
    = new DirectoryEntry("LDAP://ABC.COM.CN");
                 System.DirectoryServices.DirectorySearcher mySearcher
    = new System.DirectoryServices.DirectorySearcher(entry);

                 mySearcher.Filter
    = "(&(objectClass=user)(objectCategory=person))";

                 mySearcher.PropertiesToLoad.Add(
    "name"); //用户名
                 mySearcher.PropertiesToLoad.Add("samaccountname"); //用户帐号

                 SearchResultCollection resultCol
    = mySearcher.FindAll();

                
    foreach (SearchResult result in resultCol)
                
    {
                     ResultPropertyCollection props
    = result.Properties;

                    
    foreach (string propName in props.PropertyNames)
                    
    {
                        
    //Response.Write(props[propName][0] + "<BR>");
                        if (propName == "name")
                        
    {
                             Response.Write(props[propName][
    0] + "<BR>");
                         }

                        
    if (propName == "samaccountname")
                        
    {
                             Response.Write(props[propName][
    0] + "<BR><BR>");
                         }

                     }

                 }

             }

         }

    }

  • 相关阅读:
    block: cfq 学习01
    SAS,SATA普及文档
    如何查看盘的类型
    [转载] Linux Futex的设计与实现
    C++ std::map的安全遍历并删除元素的方法
    我的vimrc配置
    .vimrc
    RC: blkio throttle 测试
    LTTng
    基于ADL5317的雪崩光电二极管(APD)偏压控制/光功率监测电路的设计
  • 原文地址:https://www.cnblogs.com/zgqys1980/p/1281847.html
Copyright © 2020-2023  润新知