zoukankan      html  css  js  c++  java
  • c#活动目录操作

    添加引用 System.DirectoryServices
    导入命名空间 using System.DirectoryServices;

    srvip = "192.168.1.1";
       dn 
    = "DC=l,DC=com";
    user 
    = @"administrator";
     pwd 
    = "123";
     DirectoryEntry de;
    de
    = new DirectoryEntry("LDAP://" + srvip + "/" + dn, user, pwd);
    DirectorySearcher sr 
    = new DirectorySearcher(de, "(userPrincipalName=" + logname+")"); //要括起来

    string path = sr.FindOne().Properties["distinguishedName"][0].ToString();

    CN 用户名
    OU 组织
    DC 域控制器 

    userPrincipalName 登录名

    Code
  • 相关阅读:
    最小路径
    零钱兑换
    硬币
    三步问题
    区域和检索
    除数博弈
    URI和URL的辨别
    交叉编译OpenMP
    牛客挑战赛44D-数列的和
    CF1408H. Rainbow Triples
  • 原文地址:https://www.cnblogs.com/ahuo/p/676853.html
Copyright © 2011-2022 走看看