Solved

VB Web Service Project for RIS style naming in WDS

Posted on 2010-11-26
1
582 Views
Last Modified: 2012-05-10
I've trying to follow a guide I've found on a blog on the internet to create a VB web service project to create a application that allows my Windows Deployment Service to query my active directory for computer names to give me naming like RIS.

http://www.beakersoft.co.uk/2010/03/11/incremental-machine-naming-in-mdt/

The code is attached. It says to "fire up a new web service project, and add this function to it". I've added the code into a txt file, saved it with a .asmx extension and tried to run it but get the following error

Server Error in '/MDT_Names' Application.
--------------------------------------------------------------------------------

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The page must have a <%@ webservice class="MyNamespace.MyClass" ... %> directive.

Source Error:


Line 1:  <WebMethod(Description:="Returns a new Computer Name to use." & _
Line 2:  " Inputs dns domain, a prefix and OU")> _
Line 3:  Public Function GetNewName(ByVal DnsDomain As String, _
 

Source File: /mdt_names/WDSNameExtras.asmx    Line: 1


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3614


I have Visual Studio express 2010. Does this code need to be compiled? Im only used to classic asp.

I have some other .asmx files that query my active directory which i have downloaded, and they work fine so i think my IIS is setup correctly.  However these asmx files also have some dll's with them.

Any help would be much appreciated. Thanks
<WebMethod(Description:="Returns a new Computer Name to use." & _
" Inputs dns domain, a prefix and OU")> _
Public Function GetNewName(ByVal DnsDomain As String, _
ByVal NamePrefix As String) As String

'build the search, based on the passed domain, then the name prefix
Dim adRoot As New DirectoryEntry("LDAP://" & DnsDomain)
Dim dirSearch As New DirectorySearcher(adRoot, "(name=" & NamePrefix & "*)")
Dim existingNames As New Dictionary(Of String, Guid)()

'loop through the results
For Each result As SearchResult In dirSearch.FindAll()

'get the name, and create a guid holder
Dim strCurrName As String = result.Properties("name")(0).ToString.ToUpper
Dim netbootGuid As New Guid

'if we have a guid use that with this name
If result.Properties("netbootGuid").Count > 0 Then
netbootGuid = New Guid(DirectCast(result.Properties("netbootGuid")(0), Byte()))
End If

'add details to the dictonary, if they are not already there
If Not existingNames.ContainsKey(strCurrName) Then
existingNames.Add(strCurrName, netbootGuid)
End If

Next

'now try and get the next name in sequence
Dim strNextName As String = Nothing

'loop through all the avalabe machine numbers up to max of 999
For i As Int32 = 1 To 999

Dim strNameTest As String = NamePrefix & i.ToString("000")

'is this name in the list, if not we have our name
If Not existingNames.ContainsKey(strNameTest) Then
strNextName = strNameTest
Exit For
End If
Next

'return our new name
Return strNextName

End Function

Open in new window

0
Comment
Question by:ncht
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34218383
The code file needs to begin with this line
<%@ WebService Language ="Vb" Class="Calculator" %>

Check this tutorial.

http://www.vbdotnetheaven.com/UploadFile/mmehta/SimpleWebService04262005065102AM/SimpleWebService.aspx
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now