D
Daniel C. Di Vita
This worked a while back, but for some reason it is not working any
more. I am using II5 with ASP 3.0. I have created the DLL form
microsoft's site:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;248187
This is the code I am working with:
<%
Set objLogon = Server.CreateObject("LoginAdmin.ImpersonateUser")
objLogon.Logon "testuser", "password", "ourdomain"
%>
<%
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1179 = 1
' Specify user sAMAccountName.
strNTName = "ddivita"
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use the NameTranslate object to find the NetBIOS domain name from
the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain
objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)
response.write strNetBIOSDomain
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1179)
response.write strUserDN
Function Parse(strDN)
' Returns RDN of OU (top level name).
Parse = Mid(strDN, InStr(strDN, "=") + 1)
Parse = Mid(Parse, InStr(Parse, "=") + 1)
Parse = MId(Parse, 1, InStr(Parse, "=") - 4)
End Function
Function Parse2(strDN)
' Returns path of OU relative to the domain.
Parse2 = Mid(strDN, InStr(strDN, "=") + 1)
Parse2 = Mid(Parse2, InStr(Parse2, "=") - 2)
Parse2 = Left(Parse2, InStr(UCase(Parse2), "DC=") - 2)
End Function
Function Parse3(strDN)
' Returns full DN of the OU.
Parse3 = Mid(strDN, InStr(strDN, "=") + 1)
Parse3 = Mid(Parse3, InStr(Parse3, "=") - 2)
End Function
%>
Now, this worked beofre, but I am not sure what has changed. It is
like I am not authenticating using the LoginAdmin object. I get this
error when the code below the authentication executes:
(0x8007054B)
This error means that access is denied. I ran other scripts I SWEAR
worked before.
Have there been any patches to IIS that may effect this? Thanks
Daniel
more. I am using II5 with ASP 3.0. I have created the DLL form
microsoft's site:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;248187
This is the code I am working with:
<%
Set objLogon = Server.CreateObject("LoginAdmin.ImpersonateUser")
objLogon.Logon "testuser", "password", "ourdomain"
%>
<%
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1179 = 1
' Specify user sAMAccountName.
strNTName = "ddivita"
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
' Use the NameTranslate object to find the NetBIOS domain name from
the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain
objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)
response.write strNetBIOSDomain
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
strUserDN = objTrans.Get(ADS_NAME_TYPE_1179)
response.write strUserDN
Function Parse(strDN)
' Returns RDN of OU (top level name).
Parse = Mid(strDN, InStr(strDN, "=") + 1)
Parse = Mid(Parse, InStr(Parse, "=") + 1)
Parse = MId(Parse, 1, InStr(Parse, "=") - 4)
End Function
Function Parse2(strDN)
' Returns path of OU relative to the domain.
Parse2 = Mid(strDN, InStr(strDN, "=") + 1)
Parse2 = Mid(Parse2, InStr(Parse2, "=") - 2)
Parse2 = Left(Parse2, InStr(UCase(Parse2), "DC=") - 2)
End Function
Function Parse3(strDN)
' Returns full DN of the OU.
Parse3 = Mid(strDN, InStr(strDN, "=") + 1)
Parse3 = Mid(Parse3, InStr(Parse3, "=") - 2)
End Function
%>
Now, this worked beofre, but I am not sure what has changed. It is
like I am not authenticating using the LoginAdmin object. I get this
error when the code below the authentication executes:
(0x8007054B)
This error means that access is denied. I ran other scripts I SWEAR
worked before.
Have there been any patches to IIS that may effect this? Thanks
Daniel