欢迎光临
我们一直在努力

以前收集到的一些资料—ADSI,使用ASP来完成NT管理

建站超值云服务器,限时71元/月

我上次说的是如何使用adsi管理web server这次讨论adsi如何对nt进行管理
使用adsi对iis进行管理需要op4
而对nt要进行adsi管理则需要ntlm
ntlm提供以下几个对象: domain, group, and user.
通过domain对象你可以增加groups和users.
警告:
    以下的例子都将改变nt访问权限数据库;任意增加和改变nt用户的权限
使用前请仔细阅读,请只在测试的机器上运行这些程序,只到你掌握了ntlm
的工作原理为止。千万不要危害到真正主机的安全。
    只有拥有administrator或则operator权限的人才能够在运行iis机器上
更改nt的用户数据库。所以,使用anonymous权限登录是没有权限的。
当然如果使用ssl的话也能够保证安全性。
例子如下:
新建一个用户:
可以在一个独立的服务器上,也可以在一个主域服务器上新增用户
<%

                            on error resume next

                            strdomain="machinename"
                            struser="jdoe"

                            set odomain = getobject("winnt://" & strdomain)

                            set ouser = odomain.create ("user", struser)

                            if (err.number = 0) then
                            ouser.setinfo
                            ouser.setpassword "mypassword"
                            ouser.setinfo
                            set ouser=nothing
                            end if

                            set odomain=nothing
%>

新增加一个组:
<%

                            strdomain="machinename"
                            strgroup="unidentified"

                            set odomain = getobject("winnt://" & strdomain)

                            set ogroup = odomain.create ("group", strgroup)

                            ogroup.setinfo

                            set odomain=nothing
                            set ogroup=nothing
%>

把一个用户增加到一个组中.
<%
                            strdomain="machinename"
                            struser="jdoe"
                            strgroup="unidentified"

                            set odomain = getobject("winnt://" & strdomain)
                            set ogroup = odomain.getobject("group", strgroup)

                            ogroup.add ("winnt://" & strdomain & "/" & struser)

                            set odomain=nothing
                            set ogroup=nothing
%>
配置用户信息
<%

                            strdomain="machinename"
                            struser="jdoe"

                            set ouser = getobject("winnt://" & strdomain & "/" & struser)

                             setting the account expiration to 30 days from today

                            dtexpirationdate=now()
                            dtexpirationdate=dateadd("d",30,dtexpirationdate)

                            ouser.accountexpirationdate = dtexpirationdate

                             setting the full name of the user
                            ouser.fullname="joe doe"

                            ouser.setinfo()

                            set ouser=nothing
%>
继承用户
<%
                            strdomain="machinename"
                            strgroup="unidentified"

                            set group = getobject("winnt://" & strdomain & "/" & strgroup)

                            for each member in group.members   

                            if (member.class="user") then

                             here is where you would do
                             something with the user

                             end if
                            next
%>
当你是使用的nt5.0时,就不需要安装ntlm了,因为nt5.0提供对adsi的支持。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 以前收集到的一些资料—ADSI,使用ASP来完成NT管理
分享到: 更多 (0)

相关推荐

  • 暂无文章