Esempio n. 1
0
        static void Main5(string[] args)
        {
            OperateAD      ado       = new OperateAD();
            string         path      = "LDAP://192.168.31.134/OU=南宁总公司,DC=test,DC=com";
            string         adminUser = "******";
            string         password  = "******";
            DirectoryEntry entry     = ado.GetEntry(path, adminUser, password);
            string         filter    = "(&(objectclass=organizationalUnit)(ou=财务部))";
            DirectoryEntry ouEntry   = ado.GetOUEntry(entry, filter);

            if (ouEntry == null)
            {
                Console.WriteLine("要删除的组织单位不存在");
            }
            else
            {
                if (ado.DelEntry(ouEntry))
                {
                    Console.WriteLine("删除成功");
                }
                else
                {
                    Console.WriteLine("删除失败");
                }
            }
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main2(string[] args)
        {
            OperateAD      ado       = new OperateAD();
            string         path      = "LDAP://192.168.31.134/OU=某单位,DC=test,DC=com";
            string         adminUser = "******";
            string         password  = "******";
            DirectoryEntry entry     = ado.GetEntry(path, adminUser, password);
            string         filter    = "(&(objectclass=organizationalUnit)(ou=综合管理部))";
            DirectoryEntry ouEntry   = ado.GetOUEntry(entry, filter);

            if (ado.AddOUEntry(ouEntry, "行政部"))
            {
                Console.WriteLine("组织单位添加成功");
            }
            else
            {
                Console.WriteLine("组织单位添加失败");
            }

            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main4(string[] args)
        {
            //Dictionary<string, string> dir = new Dictionary<string, string>();
            //dir.Add("name", "abs");
            //dir.Add("sAMAccountName", "abs");
            //dir.Add("userPrincipalName", "abs");
            //dir.Add("userPwd", "Asd123456");
            //dir.Add("displayName", "阿巴瑟");
            //dir.Add("mail", "*****@*****.**");
            //dir.Add("department", "行政部");
            DomainUser user = new DomainUser();

            user.Name              = "leinuo";
            user.SAMAccountName    = "leinuo";
            user.UserPrincipalName = "*****@*****.**";
            user.UserPwd           = "Asd654123";
            user.Mail              = "*****@*****.**";
            user.Department        = "综合管理部";
            user.TelephoneNumber   = "15615615656";
            //AjaxResult result= Helper.SendMessage("http://192.168.31.134:8083/domainrtx/add", user);
            OperateAD      ado       = new OperateAD();
            string         path      = "LDAP://192.168.31.134/OU=某单位,DC=test,DC=com";
            string         adminUser = "******";
            string         password  = "******";
            DirectoryEntry entry     = ado.GetEntry(path, adminUser, password);
            string         filter    = "(&(objectclass=organizationalUnit)(ou=综合管理部))";
            DirectoryEntry ouEntry   = ado.GetOUEntry(entry, filter);
            DirectoryEntry userEntry = ado.GetUserEntry(entry, "leinuo");

            ado.UserMoveToOU(ouEntry, userEntry);
            if (ado.EditAccount(userEntry, user))
            {
                Console.WriteLine("成功");
            }
            else
            {
                Console.WriteLine("失败");
            }
            Console.ReadKey();
        }