Web-enabling ADSI scripts

by Bharat Suneja

With the number of scripts I’ve been writing/accumulating growing exponentially every week, it was time to web-enable stuff so others could also benefit from the automation and efficiencies these provide.

Well, it proved to be more difficult than I thought. Finally, after 2-3 sleepless nights, some things are up and running on a small web site, with more stuff to be added as I go. Used to be a big design evangelist – still am – but at times all the design stuff just gets in the way of coding! (For someone with a background in advertising, design & all things creative I’m really surprising myself with this line of thought!).

There will be time for design later – for now it’s just fun (and very rewarding) to make the functionality work!

Some lessons learnt:
i) Security: You don’t want to run this stuff on a Domain Controller. Here’s where you run into some interesting issues – that perhaps took most of the time. If the web site resides on a Member Server, IIS‘ Windows Integrated Authentication does not work for talking to the domain! Choose Basic authentication – and use SSL.

**You may have to tell IIS to explicitly use Kerberos.

cscript C:\Inetpub\AdminScripts\adsutil.vbs set w3svc/NTAuthenticationProviders “Negotiate”

ii) HTML/ASP Forms:Been a long while since I dabbled with Active Server Pages (ASP). This was a good refresher.

Forms have 2 methods – GET & POST. The GET method exposes data in the URLs like this URL –
http://somserver/cgi-bin/foo.pl?fname=Craig&lname;=Kelley
POST does not.

Form Page: first tags are in quotes to avoid this blog interpreting it as an actual form.

< "FORM" name="User" ACTION="getuserdn.asp" method="post">
Enter User Name <"input maxlength"="20" size="30" name="inputUser">

inputUser is the name of the text box, this gets passed on to the next page (ACTION) as a variable

<"input type"="submit" value="Get User Details" name="Get_DN">
<"/form">

Result Page

Head:
< %@ Language=VBScript%>
< %strUser = request.Form("inputUser")
I prefer to get the form input (inputUser) in a new variable – strUser here – for no explicit reason.
‘Then script stuff as usual
% >

The above code captures the value of the inputUser input box on the previous (form) page.

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: