最近老大交代了一个任务,用C#把Exchange AD活动目录中的指定组里面的用户信息数据取出来.
找了些资料没有特别全的了..求救大虾!
email:[email protected]
有现成的源码最好

解决方案 »

  1.   

    public class DSUser {
        public DSUser(System.DirectoryServices.DirectoryEntry user) {
          this.domainName=user.Path;
          this.Username=user.Name;
          this.Password=user.Password;
          try {
            this.FullName=Convert.ToString(user.Invoke("Get", new object[]
    {"FullName"}));
            this.Description=Convert.ToString(user.Invoke("Get", new
    object[] {"Description"}));
            this.PasswordExpired=Convert.ToInt32(user.Invoke("Get", new
    object[] {"PasswordExpired"}));
            this.RasPermissions=Convert.ToInt32(user.Invoke("Get", new
    object[] {"RasPermissions"}));
            this.MaxStorage=Convert.ToInt32(user.Invoke("Get", new object[]
    {"MaxStorage"}));
            this.PasswordAge=Convert.ToInt32(user.Invoke("Get", new object[]
    {"PasswordAge"}));
            this.HomeDirectory=Convert.ToString(user.Invoke("Get", new
    object[] {"HomeDirectory"}));
            this.LoginScript=Convert.ToString(user.Invoke("Get", new
    object[] {"LoginScript"}));
            this.HomeDirDrive=Convert.ToString(user.Invoke("Get", new
    object[] {"HomeDirDrive"}));
            this.userDirEntry=user;
          }catch(Exception e) {
            throw(new Exception("Could not load user from given
    DirectoryEntry"));
          }
        }
        public DSUser(string Username, string Password, string DomainName) {
          domainName=DomainName;
          if(domainName=="" || domainName==null)
    domainName=Environment.MachineName;
          username=Username;
          password=Password;
        }
      

  2.   

    http://www.c-sharpcorner.com/DirectoryServices.asp
      

  3.   


    public static DirectoryEntry GetDirectoryEntry(){
    DirectoryEntry de = new DirectoryEntry();
    de.Path = "LDAP://192.168.1.1/CN=Users;DC=Yourdomain";
    de.AuthenticationType = AuthenticationTypes.Secure;
    return de;
    }
    /// <summary>
    /// Method used to create an entry to the AD.
    /// Replace the path, username, and password.
    /// </summary>
    /// <returns>DirectoryEntry</returns>
    public static DirectoryEntry GetDirectoryEntry(){
    DirectoryEntry de = new DirectoryEntry();
    de.Path = "LDAP://192.168.1.1/CN=Users;DC=Yourdomain";
    de.Username = @"yourdomain\sampleuser";
    de.Password = "samplepassword";
    return de;
    }
    這樣就行了....