Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2006, 06:47 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default create subdomain

Hi,
How can I create subdomain programatically through asp code?
Ihave seen this on some weblogs.
when the user registers a subdomain is created for him like this
Username.Sitename.com

Thanks in advance for your help


 
Old January 9th, 2006, 01:18 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can use ADSI to program against the IIS configuration. It can be difficult to find out what properties you need to set, but it's quite possible to do this.

Here are some pointers:

http://www.west-wind.com/presentatio...rverConfig.htm
http://www.microsoft.com/windows2000...p/aore94th.htm
http://www.iisfaq.com/Default.aspx?tabid=2537

In addition to this, you'll need a * record for your domain pointing to your machine. That means whatever you type in before your domain name should bring you to your server. Then you can use ADSI to create new websites and set the host header to SomeName.YourDomain.Com

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 9th, 2006, 06:56 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANKS IMar

 
Old February 26th, 2006, 03:09 PM
Authorized User
 
Join Date: Feb 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to savan_thakkar Send a message via Yahoo to savan_thakkar
Default

Hi keyvanjan & Imar...
I checked the links....
But I could not create subdomain through C#,asp.net application.
Can u please explain me in a bit detail...
Thanks.

Savan
 
Old February 27th, 2006, 03:14 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Unfortunately I could not either .I just got an idea but it seems it does not work.
It seems noBody can answer this question

 
Old February 27th, 2006, 04:25 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

How does the code look like that you have been using??

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 28th, 2006, 02:03 AM
Authorized User
 
Join Date: Feb 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to savan_thakkar Send a message via Yahoo to savan_thakkar
Default

Hi,
This is the code that I m using...

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       CreateVirtualDir("savan", "sampletest", "D:\Savan\Backup\ChoicesWildNet\Application Sohel")
End Sub

Private Sub CreateVirtualDir(ByVal WebSite As String, ByVal AppName As String, ByVal Path As String)

        Dim IISSchema As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/Schema/AppIsolated")
        'Dim CanCreate As Boolean = Not IISSchema.Properties("Syntax").Value.ToString.ToUp per() = "BOOLEAN"
        IISSchema.Dispose()

        ' If CanCreate Then
        Dim PathCreated As Boolean

        Try
            Dim IISAdmin As New System.DirectoryServices.DirectoryEntry("IIS://" & WebSite & "/W3SVC/1/Root")

            'make sure folder exists
            If Not System.IO.Directory.Exists(Path) Then
                System.IO.Directory.CreateDirectory(Path)
                PathCreated = True
            End If

            'If the virtual directory already exists then delete it
            For Each VD As System.DirectoryServices.DirectoryEntry In IISAdmin.Children
                If VD.Name = AppName Then
                    IISAdmin.Invoke("Delete", New String() {VD.SchemaClassName, AppName})
                    IISAdmin.CommitChanges()
                    Exit For
                End If
            Next VD

            'Create and setup new virtual directory
            Dim VDir As System.DirectoryServices.DirectoryEntry = IISAdmin.Children.Add(AppName, "IIsWebVirtualDir")
            VDir.Properties("Path").Item(0) = Path
            VDir.Properties("AppFriendlyName").Item(0) = AppName
            VDir.Properties("EnableDirBrowsing").Item(0) = False
            VDir.Properties("AccessRead").Item(0) = True
            VDir.Properties("AccessExecute").Item(0) = True
            VDir.Properties("AccessWrite").Item(0) = False
            VDir.Properties("AccessScript").Item(0) = True
            VDir.Properties("AuthNTLM").Item(0) = True
            VDir.Properties("EnableDefaultDoc").Item(0) = True
            VDir.Properties("DefaultDoc").Item(0) = "default.htm,default.aspx,default.asp"
            VDir.Properties("AspEnableParentPaths").Item(0) = True
            VDir.CommitChanges()

            'the following are acceptable params
            'INPROC = 0
            'OUTPROC = 1
            'POOLED = 2
            VDir.Invoke("AppCreate", 1)

        Catch Ex As Exception
            If PathCreated Then
                System.IO.Directory.Delete(Path)
            End If
            Response.Write(Ex.Message.ToString())
        End Try
        ' End If
    End Sub

Savan
 
Old February 28th, 2006, 02:59 AM
Authorized User
 
Join Date: Feb 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to savan_thakkar Send a message via Yahoo to savan_thakkar
Default


It would be better if you can tell me What type of permission need to be set in IIS
in order to create Virtual Directory in this way.

Thanks


Savan
 
Old February 28th, 2006, 05:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am not 100% user, but I think you need Administrative privileges, or at least that of a Power User.

However, it's easy to find out using Windows XP's Run As feature.

Compile your code in an exe and run it with different user accounts....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Help Me Lift You Up by This Mortal Coil (Track 15 from the album: Blood) What's This?
 
Old May 15th, 2006, 06:45 AM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to maulik@hitechinfosoft.com Send a message via Yahoo to maulik@hitechinfosoft.com
Default

Hello Savan_thakkar

I have faced the samw problem as U.
I eannt to create the subdomain through ASP.Net

For ex. Suppose my site name is www.xxx.com and one of my client register with his firm name as "yyy". So domain for his site would be "www.yyy.xxx.com"






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to maintain session between Domain &subdomain im.imrankhan PHP How-To 1 September 5th, 2008 12:44 PM
Error giving when i create the Subdomain Surjit Classic ASP Professional 0 April 18th, 2008 06:17 AM
Create generic XSL Template to create table Venkatachalapathy XSLT 5 March 11th, 2008 07:49 AM
create subdomain keyvanjan ASP.NET 1.0 and 1.1 Professional 8 February 20th, 2006 05:44 AM
how to create editor ibrahim C# 2 December 17th, 2003 11:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.