Hi Everyone,
I am encountering a problem withthe following code. It works great when the ASP page sits in IIS on my DC, but if moved to a member server it breaks saying "Table Does Not Exist."
I need to have the code work if running on a member server. Can anyone offer any advice?
Thanks in advance, any help is greatly appreciated.
I am encountering a problem withthe following code. It works great when the ASP page sits in IIS on my DC, but if moved to a member server it breaks saying "Table Does Not Exist."
I need to have the code work if running on a member server. Can anyone offer any advice?
Code:
<%@ LANGUAGE="VBSCRIPT" %>
<%
'==========================================================================
'
' NAME: showOU.asp
'
' AUTHOR: Mark D. MacLachlan , Microsoft
' URL: [URL unfurl="true"]http://www.microsoft.com[/URL]
' DATE : 12/13/2004
' COPYWRITE (C) 2004
' COMMENT:
'
'==========================================================================
Set WSHNetwork = CreateObject("WScript.Network")
userstring = WSHNetwork.UserName
UserOU = SearchOU(userstring)
'************************************************************************
%>
<html>
<head>
<title>Show OU Info</title>
</head>
<body bgcolor="#99CCFF" style="text-align: center" link="#000000" vlink="#000000" alink="#99CCFF">
<%
Response.Write "User is located in:" & UserOU
%>
</body>
</html>
<%
Public Function SearchOU(ByVal vSAN)
' Function: SearchDistinguishedName
' Description: Searches the DistinguishedName for a given SamAccountName
' Parameters: ByVal vSAN - The SamAccountName to search
' Returns: The DistinguishedName Name
Dim oRootDSE, oConnection, oCommand, oRecordSet
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
">;(&(objectCategory=User)(samAccountName=" & vSAN & "));distinguishedName, cn;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
FullDN = Len(oRecordSet.Fields("DistinguishedName"))
SubDN = Len(oRecordSet.Fields("cn"))+4
OULength = FullDN - SubDN
OUString = Right(oRecordSet.Fields("DistinguishedName"),OULength)
SearchOU = OUString
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function
%>
Thanks in advance, any help is greatly appreciated.