您的位置:程序门 -> .net技术 -> c#



请教如何在win2003系统中通过程序或者脚本添加用户组和用户?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请教如何在win2003系统中通过程序或者脚本添加用户组和用户?[已结贴,结贴人:jinniu]
发表于:2007-06-05 10:45:57 楼主
我想知道在c#或者vb.net中如何通过程序来添加用户组和用户。
我大楷晓得用system.directoryservices类来处理。不过现在我没有什么头绪,以前也没有涉及过。希望那位能提供一个稍微详细一点的解决方案。
多谢!
发表于:2007-06-05 10:49:441楼 得分:40
how   to   add   a   user   to   the   local   system   by   using   directory   services   and   visual   c#

ref:http://support.microsoft.com/kb/306273/en-us/
发表于:2007-06-05 10:49:522楼 得分:10
how   to   add   a   user   to   the   local   system   by   using   directory   services   and   visual   c#
kb306273
http://support.microsoft.com/kb/306273/en-us
发表于:2007-06-05 10:52:553楼 得分:20
如果不限于directoryservices,则方法有很多了。
wmi、dos命令、api……
发表于:2007-06-05 10:53:134楼 得分:10
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;
namespace   windowsapplication29
{
        public   partial   class   form1   :   form
        {
                public   form1()
                {
                        initializecomponent();
                       
                }

                private   void   button1_click(object   sender,   eventargs   e)
                {
                        try
                        {
                                directoryentry   ad   =   new   directoryentry( "winnt:// "   +
                                                                        environment.machinename   +   ",computer ");
                                directoryentry   newuser   =   ad.children.add( "testuser1 ",   "user ");
                                newuser.invoke( "setpassword ",   new   object[]   {   "#12345abc "   });
                                newuser.invoke( "put ",   new   object[]   {   "description ",   "test   user   from   .net "   });
                                newuser.commitchanges();
                                directoryentry   grp;

                                grp   =   ad.children.find( "guests ",   "group ");
                                if   (grp   !=   null)   {   grp.invoke( "add ",   new   object[]   {   newuser.path.tostring()   });   }
                                console.writeline( "account   created   successfully ");
                                console.readline();
                        }
                        catch   (exception   ex)
                        {
                                console.writeline(ex.message);
                                console.readline();

                        }
                         
                }
               

        }
}
发表于:2007-06-05 10:53:495楼 得分:10
大家帮忙解决一下这个问题吧,谢谢了..............
http://community.csdn.net/expert/topic/5581/5581312.xml?temp=.6539881
发表于:2007-06-05 10:54:236楼 得分:10
要使用system.directoryservices似乎要系统支持的。
似乎要在域里才可以
发表于:2007-06-05 10:58:017楼 得分:20
net   user   /add
发表于:2007-06-05 10:58:288楼 得分:80
http://www.xrss.cn/info/13717.html
http://tonyqus.cnblogs.com/archive/2004/12/26/82120.aspx
发表于:2007-06-05 11:01:029楼 得分:0
看了一下楼上上的文章,可以解决问题
发表于:2007-06-05 11:04:2510楼 得分:0
都是高手啊!
发表于:2007-06-05 11:10:1311楼 得分:0
不懂,帮顶
发表于:2007-06-07 09:48:4712楼 得分:0
那位大哥还有高见?
发表于:2007-06-07 09:49:1813楼 得分:0
帮帮忙看一下呀!


快速检索

最新资讯
热门点击