All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP小技巧:避免表单的重复提交的方法_php资料_编程技术
SQLServer2005中的XML选项详解(2)_[SQL Server教程]
SQL SERVER 和EXCEL的数据导入导出_[SQL Server教程]
C#,中启动进程的三种方法_[Asp.Net教程]
PHP学习:字符串操作入门教程_php资料_编程技术
TreeView菜单导航的应用
用代码画折线图/柱形图/条形图/饼图_.net资料_编程技术
ASP.NET底层架构探索之IE6的革新_.net资料_编程技术
教你用PHP写MySQL数据库的用户认证系统_[PHP教程]
Delphi以图形按钮显示的界面
Reading number is top 10 pictures
运动的范冰冰2
2012 national geographic daily picture6
Sora aoi possession photo2
中国的十元人民币的秘密
The real super beauty9
More attractive than sora aoi1
Beauty ZhiHuiLin1
Chinese paper-cut grilles art appreciation2
乳娘帕梅拉安德森3
Summer is most suitable for young people to travel in China8
Download software ranking
matrix2
Prostitutes diary
VC++6.0简体中文版
Take off clothes to survival
打鸟视频
好色的外科大夫
ASP.NET.2.0.XML.高级编程(第3版)
Sora aoi, the nurse, uniform ,nursing assistant
天龙八部最新服务端
Popkart Cracked versions Mobile phone games
qq published in(发表于) 2014/7/11 9:15:44 Edit(编辑)
C#中 DirectoryEntry组件应用实例

C#中 DirectoryEntry组件应用实例

C#中 DirectoryEntry组件应用实例

DirectoryEntry组件

1. 功能

DirectoryEntry类封装Active Directory层次结构中的节点或对象,使用该类可以绑定到对象,或者读取和更新属性。图1所示为DirectoryEntry组件。



图1 DirectoryEntry组件

2.属性

DirectoryEntry组件常用属性及说明如表1所示。



表1 DirectoryEntry组件常用属性及说明

下面对比较重要的属性进行详细介绍。

Path属性:用于获取或设置DirectoryEntry对象的路径,默认值为空字符串(“”)。

语法:

public string Path { get; set; }
属性值:DirectoryEntry对象的路径,默认值为空字符串(“”)。

示例

Path属性的使用

本示例主要是设置Path属性,将本机上的用户名、工作组添加到treeview控件中。其运行结果如图2所示。



图2 Path属性

程序主要代码如下:


完整程序代码如下:

★★★★★主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_26

{

static class Program

{

///



/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmDirectoryEntry());

}

}

}

★★★★★frmDirectoryEntry窗体设计文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.DirectoryServices;

using System.Diagnostics;

namespace _8_26

{

public partial class frmDirectoryEntry : Form

{

public frmDirectoryEntry()

{

InitializeComponent();

}

//以下函数实现路径及属性的添加功能

private void AddPathAndProperties(TreeNode node, DirectoryEntry entry)

{

node.Nodes.Add(new TreeNode("Path:" + entry.Path));

TreeNode propertyNode = new TreeNode("Properties");

node.Nodes.Add(propertyNode);

foreach (string propertyName in entry.Properties.PropertyNames)

{

string oneNode = propertyName + ":" + entry.Properties[propertyName][0].ToString();

propertyNode.Nodes.Add(new TreeNode(oneNode));

}

}

private void frmDirectoryEntry_Load(object sender, EventArgs e)

{

//entryPC.Path = "WinNT://192.168.1.96/ZHY";

entryPC.Path = "WinNT://workgroup/Localhost";//Workgroup计算机所处的组//ZHY计算机名

//entryPC.Path = "LDAP://ZHY/rootDSE";

TreeNode users = new TreeNode("Users");

TreeNode groups = new TreeNode("Groups");

TreeNode services = new TreeNode("Services");

viewPC.Nodes.AddRange(new TreeNode[] { users, groups, services });

foreach (DirectoryEntry child in entryPC.Children)

{

TreeNode newNode = new TreeNode(child.Name);

switch (child.SchemaClassName)

{

case "User":

users.Nodes.Add(newNode);

break;

case "Group":

groups.Nodes.Add(newNode);

break;

case "Service":

services.Nodes.Add(newNode);

break;

}

AddPathAndProperties(newNode, child);

//http://www.isstudy.com

}

}

}//

}

★★★★★frmDirectoryEntry窗体代码文件完整程序代码★★★★★


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.