For an application that is interacting with different webservers and platforms I now need to interact with Microsoft IIS.
My goal is 'simple', retrieve a list of websites with a https binding, via golang.
After some googling it looks like I need to use the Microsoft.Web.Administration.dll that provides some classes that would allow me todo the job:
The Microsoft.Web.Administration namespace contains classes that a developer can use to administer IIS Manager. With the classes in this namespace, an administrator can read and write configuration information to ApplicationHost.config, Web.config, and Administration.config files.
The classes in the Microsoft.Web.Administration namespace contain a series of convenient top-level objects that allow the developer to perform administrative tasks. The different logical objects available include sites, applications, application pools, application domains, virtual directories, and worker processes. You can use the API to obtain and work with the configuration and state of these objects and to perform such actions as creating a site, starting or stopping a site, deleting an application pool, recycling an application pool, and even unloading application domains.
The namespace documentation on the msdn website:
And some (old) usage examples:
Now would it be a few minutes work to build something like this in the by Microsoft supported languages but I hope someone could help me started in golang as I can't find a lot of documentation or examples for this (besides
w32 wrapper that looks really good!).
Loading the ddl is simple and completes successfully:
mwadmin = syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")
But then I need to find a procedure:
mwadminSite = mwadmin.MustFindProc("SiteCollection")
Which always results in an error like this:
panic: Failed to find Microsoft.Web.Administration procedure in c:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll: The specified procedure could not be found.
Now I think that I can't load a class as a procedure... but how can I use this .dll then as I can't find any other way to get started with a dll file by linking a procedure with MustFindProc, FindProc or Find in combination with the NewLazyDLL delayed loading.
My full example code :-)
package main
import (
"syscall"
)
var (
mwadmin = syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")
mwadminSite = mwadmin.MustFindProc("Microsoft.Web.Administration")
)
func main() {
}