473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Help with vbscript in asp.net

Set objUser = GetObject("WinNT://WALKER_MORRIS/hup^,user")
If objUser.IsAccountLocked = True Then .......

I am using the above code as part of my asp.net web application.
I have tested the code and it works fine except when the code executes
as part of my webpage i receive the following error:-

ActiveX component can't create object 'CreateObject'

Any ideas?

Oct 10 '07 #1
16 1647
<te******@gmail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...
Set objUser = GetObject("WinNT://WALKER_MORRIS/hup^,user")
If objUser.IsAccountLocked = True Then .......

I am using the above code as part of my asp.net web application.
I have tested the code and it works fine except when the code executes
as part of my webpage i receive the following error:-

ActiveX component can't create object 'CreateObject'

Any ideas?
That's Classic ASP code...

To interface with ActiveDirectory in .NET, you need to use the
System.DirectoryServices namespace...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 10 '07 #2
Also can you confirm if this code is running on the client via <script>
tags? If it is then you're probably running into security issues, you can't
just create any old ActiveX object on the client.

<te******@gmail.comwrote in message
news:11**********************@o80g2000hse.googlegr oups.com...
Set objUser = GetObject("WinNT://WALKER_MORRIS/hup^,user")
If objUser.IsAccountLocked = True Then .......

I am using the above code as part of my asp.net web application.
I have tested the code and it works fine except when the code executes
as part of my webpage i receive the following error:-

ActiveX component can't create object 'CreateObject'

Any ideas?

Oct 10 '07 #3
On 10 Oct, 10:05, "Aidy" <a...@xxnoemailxx.comwrote:
Also can you confirm if this code is running on the client via <script>
tags? If it is then you're probably running into security issues, you can't
just create any old ActiveX object on the client.

<teeja...@gmail.comwrote in message

news:11**********************@o80g2000hse.googlegr oups.com...
Set objUser = GetObject("WinNT://WALKER_MORRIS/hup^,user")
If objUser.IsAccountLocked = True Then .......
I am using the above code as part of my asp.net web application.
I have tested the code and it works fine except when the code executes
as part of my webpage i receive the following error:-
ActiveX component can't create object 'CreateObject'
Any ideas?- Hide quoted text -

- Show quoted text -
Yes I am running the code on the client using <scripttags
Think this is probably a security issue.
Is there any way round this?

Oct 10 '07 #4
<te******@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Yes I am running the code on the client using <scripttags
You didn't say that in your original post...
Think this is probably a security issue.
Is there any way round this?
Do your AD work server-side using the System.DirectoryServices namespace,
after setting ASP.NET up to impersonate a user with sufficient privileges...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 10 '07 #5
On 10 Oct, 10:25, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<teeja...@gmail.comwrote in message

news:11**********************@22g2000hsm.googlegro ups.com...
Yes I am running the code on the client using <scripttags

You didn't say that in your original post...
Think this is probably a security issue.
Is there any way round this?

Do your AD work server-side using the System.DirectoryServices namespace,
after setting ASP.NET up to impersonate a user with sufficient privileges...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
This works when I run it on my webserver. Not in VS but when i go
into my web browser and type the address http://computername/stripnet
If i run from any other application i get the a run time error.
Do i have to add the directoryservices.dll into my root web folder or
something?

Oct 12 '07 #6
<te******@gmail.comwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
Do i have to add the directoryservices.dll into my root web folder or
something?
You have to add a reference to it in your project...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 12 '07 #7
On 12 Oct, 10:31, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<teeja...@gmail.comwrote in message

news:11**********************@y27g2000pre.googlegr oups.com...
Do i have to add the directoryservices.dll into my root web folder or
something?

You have to add a reference to it in your project...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
I have added the reference to the project.

Oct 12 '07 #8
On 12 Oct, 10:43, "teeja...@gmail.com" <teeja...@gmail.comwrote:
On 12 Oct, 10:31, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<teeja...@gmail.comwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
Do i have to add the directoryservices.dll into my root web folder or
something?
You have to add a reference to it in your project...
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

I have added the reference to the project.
i get the following error

Server Error in '/StripNET' Application.

Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons).
It could, however, be viewed by browsers running on the local server
machine.

if i remove the part using directory services it runs without an error.

Oct 12 '07 #9
<te******@gmail.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.com...
>I have added the reference to the project.

i get the following error

Server Error in '/StripNET' Application.
Then there's either a bug in your code somewhere, or you're not using
Windows 2003...

Presumably your code looks something like this:
http://en.csharp-online.net/User_Man...ccount_Lockout

How are you actually referencing the User object...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 12 '07 #10
On 12 Oct, 11:31, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<teeja...@gmail.comwrote in message

news:11**********************@e34g2000pro.googlegr oups.com...
I have added the reference to the project.
i get the following error
Server Error in '/StripNET' Application.

Then there's either a bug in your code somewhere, or you're not using
Windows 2003...

Presumably your code looks something like this:http://en.csharp-online.net/User_Man..._Directory%E2%...

How are you actually referencing the User object...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
No, the code works fine. It works fine on my PC which is running
IIS. Even if I am browsing to it out of VS. But if any other user
tried to use it on their machine it throws up the error. If i remove
this code that checks if the account is locked out then other users
don't receive the error.

my code is as follows:-

imports system.directoryservices

' some code above here which is not causing the problem.
Dim objUser As New DirectoryEntry("LDAP://" & strLDAP)
Dim objSearcher As DirectorySearcher = New
DirectorySearcher(objUser)
Dim objResults As SearchResultCollection
Dim objResult As SearchResult
Const lockoutFlag As Integer = 16

objSearcher.PropertiesToLoad.Add("msds-User-Account-Control-
Computed")

objResults = objSearcher.FindAll()

For Each objResult In objResults
Dim status As Integer =
DirectCast(objResult.Properties("msds-User-Account-Control-Computed")
(0), Integer)
If (status And lockoutFlag) = lockoutFlag Then
IsAccountLocked = True
Session("LDAP") = strLDAP
Else
IsAccountLocked = False
End If
Next

objUser.Close()
objUser.Dispose()
thanks for your help by the way. I really appreciate it!

Oct 12 '07 #11
<te******@gmail.comwrote in message
news:11*********************@v29g2000prd.googlegro ups.com...
On 12 Oct, 11:31, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
><teeja...@gmail.comwrote in message

news:11**********************@e34g2000pro.googleg roups.com...
>I have added the reference to the project.
i get the following error
Server Error in '/StripNET' Application.

Then there's either a bug in your code somewhere, or you're not using
Windows 2003...

Presumably your code looks something like
this:http://en.csharp-online.net/User_Man..._Directory%E2%...

How are you actually referencing the User object...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

No, the code works fine. It works fine on my PC which is running
IIS. Even if I am browsing to it out of VS. But if any other user
tried to use it on their machine it throws up the error. If i remove
this code that checks if the account is locked out then other users
don't receive the error.

my code is as follows:-

imports system.directoryservices

' some code above here which is not causing the problem.
Dim objUser As New DirectoryEntry("LDAP://" & strLDAP)
Dim objSearcher As DirectorySearcher = New
DirectorySearcher(objUser)
Dim objResults As SearchResultCollection
Dim objResult As SearchResult
Const lockoutFlag As Integer = 16

objSearcher.PropertiesToLoad.Add("msds-User-Account-Control-
Computed")

objResults = objSearcher.FindAll()

For Each objResult In objResults
Dim status As Integer =
DirectCast(objResult.Properties("msds-User-Account-Control-Computed")
(0), Integer)
If (status And lockoutFlag) = lockoutFlag Then
IsAccountLocked = True
Session("LDAP") = strLDAP
Else
IsAccountLocked = False
End If
Next

objUser.Close()
objUser.Dispose()
thanks for your help by the way. I really appreciate it!


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 12 '07 #12
<te******@gmail.comwrote in message
news:11*********************@v29g2000prd.googlegro ups.com...
No, the code works fine. It works fine on my PC which is running
IIS. Even if I am browsing to it out of VS. But if any other user
tried to use it on their machine it throws up the error. If i remove
this code that checks if the account is locked out then other users
don't receive the error.
As I mentioned a couple of replies back, the user under which ASP.NET runs
by default doesn't have sufficient privileges to query ActiveDirectory, so
you will need to set up impersonation. Pretty much any standard DomainUser
account will do unless you need to make changes to AD objects...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 12 '07 #13
On 10 Oct, 10:05, "Aidy" <a...@xxnoemailxx.comwrote:
Also can you confirm if this code is running on the client via <script>
tags? If it is then you're probably running into security issues, you can't
just create any old ActiveX object on the client.

<teeja...@gmail.comwrote in message

news:11**********************@o80g2000hse.googlegr oups.com...
Set objUser = GetObject("WinNT://WALKER_MORRIS/hup^,user")
If objUser.IsAccountLocked = True Then .......
I am using the above code as part of my asp.net web application.
I have tested the code and it works fine except when the code executes
as part of my webpage i receive the following error:-
ActiveX component can't create object 'CreateObject'
Any ideas?- Hide quoted text -

- Show quoted text -
Is ther a way around this? I have decided to do my AD work server
side but now I am wanting to add some scripts that will need to be run
client side and will need to create activex objects?

Oct 22 '07 #14
Is ther a way around this? I have decided to do my AD work server
side but now I am wanting to add some scripts that will need to be run
client side and will need to create activex objects?
You'll need to mark the objects as safe in each user's registry, or (better)
develop your own activex control that will do the coding for you. Users
will need to accept to download and install the activex control.
Oct 22 '07 #15
On 22 Oct, 16:29, "Aidy" <a...@xxnoemailxx.comwrote:
Is ther a way around this? I have decided to do my AD work server
side but now I am wanting to add some scripts that will need to be run
client side and will need to create activex objects?

You'll need to mark the objects as safe in each user's registry, or (better)
develop your own activex control that will do the coding for you. Users
will need to accept to download and install the activex control.
How do I mark the object as safe in a users registry?

Oct 24 '07 #16
http://msdn2.microsoft.com/en-us/library/aa751977.aspx

<te******@gmail.comwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
On 22 Oct, 16:29, "Aidy" <a...@xxnoemailxx.comwrote:
Is ther a way around this? I have decided to do my AD work server
side but now I am wanting to add some scripts that will need to be run
client side and will need to create activex objects?

You'll need to mark the objects as safe in each user's registry, or
(better)
develop your own activex control that will do the coding for you. Users
will need to accept to download and install the activex control.

How do I mark the object as safe in a users registry?

Oct 24 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
8
by: Jose | last post by:
Can anyone help? I try to put all my function in a separate .ASP file under scriptlib folder but when I call any function from the such asp file do not work meanwhile if I put the code inside...
8
by: chuck clark | last post by:
Hi, I am sorry if this is not the most appropriate group to ask this in (if not, please point me in the right direction). I am following examples from this page,...
1
by: James Leech | last post by:
Hi guys I am trying to use an Access function that I found on the web from within an asp page, but I can't seem to correct all the subtle differances between the two languages. When I run a...
9
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction...
2
by: Goober | last post by:
I have the following default.aspx page that works properly. However, what I want to do is to link the graphics within it (that are hard coded now in the default web page) to our corporate...
1
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>...
1
by: David | last post by:
Hi, I cannot get the following (MS Access) SQL statement working in my asp page, please can anyone help me ? Thanks :-) ------------------------------------------------ <% strQuery =...
18
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not...
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.