ADSI,使用ASP来完成NT管理

ADSI,使用ASP来完成NT管理

关键词:ASP

我上次说的是如何使用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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值