zoukankan      html  css  js  c++  java
  • 列出域中所有用户的代码 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>");
                         }

                     }

                 }

             }

         }

    }

  • 相关阅读:
    【闲暇研究】某问道,问问,道道宠物素材整理
    小米手机刷机,官方教程。
    【闲暇研究】某问道,每日极品道具体验礼包。
    【闲暇研究】某问道,悟道只能用银元宝。
    Windows Server 2016从Evaluation评估版转换成正式版
    【闲暇研究】某问道,仙元、道具合成的修改,与参考文件。
    关于小米手机安装APP总是提示“与已安装应用签名不同”的问题
    WebStorm的快捷键,技巧
    Webstorm(常见配置+Emmet简单语法)
    05-方法重写
  • 原文地址:https://www.cnblogs.com/zgqys1980/p/1281847.html
Copyright © 2011-2022 走看看