E
Enigma Webmaster
Hi All,
We've written a couple of functions which, when run in VB6 work fine and
allow AD users to be updated. When we include the code into an ASP Page and
try and update a users information (i.e. Mobile Phone Number) we get a
failure as below...
Error Number:- -2147467259 Automation error Unspecified error
Can anyone see why this is happenning? Whe nwe run the DLL from VB6 or
Studio.NET then it works fine. We've checked the Security permissions on
the WebServer and it uses the Administrator Account.
Thanks in anticipation.
KMP
TEST HARNESS ASP PAGE
<html>
<%@ Language=VBScript %>
<%
dim myobj,retval
set myObj = createobject("TinopADutilityV2.ActiveDirectory")
retVal = myObj.ConnecttoLDAP("Username","Interactive") ' retVal = 1 if
successful, 0 otherwise
response.write(myObj.GetInfo("cn")) & "<br>" ' Display
Username to show we have right user
retVal = myObj.UpdateInfo("Mobile", "07990 123456") ' Update
Details. retVal = 1 if OK, otherwise -1
myobj.closeLDAP
%>
</html>
VB6 DLL SourceCode
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ActiveDirectory"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'***************************************
'* *
'* ActiveX dll Developed to interact *
'* with Active Dirctory.... *
'* Created by E Strangler 31/7/2004*
'* *
'***************************************
Option Explicit
Dim objUserInfo As Object
Dim strLDAPAddress As String
Public Function ConnecttoLDAP(ByVal strDisName As Variant, ByVal strOrgUnit
As Variant) As Boolean
On Error GoTo errCleanUp
Set objUserInfo = GetObject("LDAP://CN=" & strDisName & ",OU=" &
strOrgUnit & ",DC=AgendaTV,DC=Co,DC=UK")
ConnecttoLDAP = True
Exit Function
errCleanUp:
'MsgBox ("An error has occurred. " & Err.Description)
ConnecttoLDAP = False
End Function
Public Function UpdateInfo(ByVal strFieldName As Variant, ByVal strData As
Variant) As Long
On Error GoTo Err_Handler
'Update with new data
objUserInfo.put strFieldName, strData
'Commit to the directory.
objUserInfo.SetInfo
UpdateInfo = 1
Exit Function
Err_Handler:
UpdateInfo = -1 'If execute fail then return -1
End Function
Public Function GetInfo(ByVal strFieldName As Variant) As Variant
'Returns data specified by the field name
GetInfo = objUserInfo.Get(strFieldName)
End Function
Public Function CloseLDAP() As Long
'Destroy object
Set objUserInfo = Nothing
End Function
We've written a couple of functions which, when run in VB6 work fine and
allow AD users to be updated. When we include the code into an ASP Page and
try and update a users information (i.e. Mobile Phone Number) we get a
failure as below...
Error Number:- -2147467259 Automation error Unspecified error
Can anyone see why this is happenning? Whe nwe run the DLL from VB6 or
Studio.NET then it works fine. We've checked the Security permissions on
the WebServer and it uses the Administrator Account.
Thanks in anticipation.
KMP
TEST HARNESS ASP PAGE
<html>
<%@ Language=VBScript %>
<%
dim myobj,retval
set myObj = createobject("TinopADutilityV2.ActiveDirectory")
retVal = myObj.ConnecttoLDAP("Username","Interactive") ' retVal = 1 if
successful, 0 otherwise
response.write(myObj.GetInfo("cn")) & "<br>" ' Display
Username to show we have right user
retVal = myObj.UpdateInfo("Mobile", "07990 123456") ' Update
Details. retVal = 1 if OK, otherwise -1
myobj.closeLDAP
%>
</html>
VB6 DLL SourceCode
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ActiveDirectory"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'***************************************
'* *
'* ActiveX dll Developed to interact *
'* with Active Dirctory.... *
'* Created by E Strangler 31/7/2004*
'* *
'***************************************
Option Explicit
Dim objUserInfo As Object
Dim strLDAPAddress As String
Public Function ConnecttoLDAP(ByVal strDisName As Variant, ByVal strOrgUnit
As Variant) As Boolean
On Error GoTo errCleanUp
Set objUserInfo = GetObject("LDAP://CN=" & strDisName & ",OU=" &
strOrgUnit & ",DC=AgendaTV,DC=Co,DC=UK")
ConnecttoLDAP = True
Exit Function
errCleanUp:
'MsgBox ("An error has occurred. " & Err.Description)
ConnecttoLDAP = False
End Function
Public Function UpdateInfo(ByVal strFieldName As Variant, ByVal strData As
Variant) As Long
On Error GoTo Err_Handler
'Update with new data
objUserInfo.put strFieldName, strData
'Commit to the directory.
objUserInfo.SetInfo
UpdateInfo = 1
Exit Function
Err_Handler:
UpdateInfo = -1 'If execute fail then return -1
End Function
Public Function GetInfo(ByVal strFieldName As Variant) As Variant
'Returns data specified by the field name
GetInfo = objUserInfo.Get(strFieldName)
End Function
Public Function CloseLDAP() As Long
'Destroy object
Set objUserInfo = Nothing
End Function