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>");
                         }

                     }

                 }

             }

         }

    }

  • 相关阅读:
    gridview把textbox的值修改还是旧值的解决方法
    [转载]FMS Dev Guide学习笔记(验证客户端二)
    推荐几个Adobe Flex Builder 3的插件(代码格式化和fms服务器通讯文件(main.asc)编写)
    淘宝装修新旺铺如何让店招导航栏透明?
    淘宝店面怎么装修(不花分毫,玩转淘宝)
    教你处理明暗不匀的宝贝照片
    淘宝店铺装修 免费扶植版教程
    淘宝店铺(宝贝描述模板)克隆攻略
    如何用淘宝助理上传宝贝装修模板
    淘宝商城推广方案书
  • 原文地址:https://www.cnblogs.com/zgqys1980/p/1281847.html
Copyright © 2011-2022 走看看