日期:2014-05-17  浏览次数:20885 次

asp开发中如何结合windows中的域达到windows验证
asp开发中如何结合windows中的域达到windows验证

------解决方案--------------------
a.asp:
<form action= "b.asp " method= "post ">
域用户: <input type=text name=id> <br/>
域密码: <input type=text name=pwd> <br/>
登陆域: <input type=text name=domain> <br/>
<input name=sub type=submit value= "提交 ">
</form>

b.asp:
<script language=javascript RUNAT= "SERVER ">
function logonDoADLogon(p_strDomain, p_strUserID, p_strPWD)
{ //return true;
var f_oIADS, f_oUser, f_oContainer;
var f_blnRet = true;

try
{
var f_oIADS = GetObject( 'WinNT: ');
f_oContainer = f_oIADS.OpenDSObject( 'WinNT:// ' + p_strDomain, p_strDomain + "\\ " + p_strUserID, p_strPWD, 0);

delete f_oContainer;
delete f_oIADS;
}
catch (e)
{
return false;
}

try
{
var objUser = GetObject( "WinNT:// " + p_strDomain + "/ " + p_strUserID );
delete objUser;
}
catch(e){
return false;
}

return true;
}
</script>

<%
id=trim(request( "id "))
pwd=trim(request( "pwd "))
domain=trim(request( "domain "))
if logonDoADLogon(domain,id,pwd) then
response.write "True "
else
response.write "False "
end if
%>