Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Loop to fill in a string

Posted on 2008-10-02
6
Medium Priority
?
298 Views
Last Modified: 2013-11-07
I have a web address I need to create from words in a string.  The location string will change and might have more or less in it, but looks something like:

CN=SerialNumber, OU=Desktops, OU=Home Office, OU=US, OU=Devices

The web page address that I need created would look like:

http://TEST:3467/ldap/browse.tsp?dn=CN%SerialNumber%2c+OU%3dDesktops%2c+OU%3dHome+Office%2c+OU%3dUS%2c+OU%3dDevices%2c+DC%3dtestdomain%2c+DC%3dcom%2c

How can I use vb2005 net to create this web address based on the location string.  The location string will always start with a CN=, but might have a single or multiple OU=.

Hope that makes sense.  Chad
0
Comment
Question by:chadmanvb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22628704
do you mean how to encode the string to have the % codes?
0
 

Author Comment

by:chadmanvb
ID: 22629095
Sorry, I mean I would like to take my location string:
CN=SerialNumber, OU=Desktops, OU=Home Office, OU=US, OU=Devices

And use that to create a new string that will be the web page.  So it would somehow take create:

String1 = SerialNumber.replace(" ","+")
String2= Desktops.replace(" ","+")
String3= Home Office.replace(" ","+")
String4= US.replace(" ","+")
String5=Devices.replace(" ","+")

Webstring="http://TEST:3467/ldap/browse.tsp?dn=CN%" & String "1%2c+OU%3d" & String2 & "2%2c+OU%3d" "String3 & "%2c+OU%3d" & String4 & "%2c+OU%3d" String5 & "%2c+DC%3dtestdomain%2c+DC%3dcom%2c"

I am just not sure how to create all of these strings from my location string.  I think I could do it if I knew it would always contain 5 variables, but it could contain more or less.  Chad
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 1200 total points
ID: 22629365
there is a ready-made function for this. Having your string yet concatenated, use:

Dim s as String = "CN=SerialNumber, OU=Desktops, OU=Home Office, OU=US, OU=Devices"

Dim encoded as String = HttpUtility.UrlEncode(s)

You will need
Imports System.Web


0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:chadmanvb
ID: 22629406
Could you explain how this works?  I am not able to get it working.  Chad
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 800 total points
ID: 22629456
I don't do web stuff so I though that was a pretty cool answer jaime...  =)

For WinForms, I had to add a Reference to System.Web:

        ' For WinForms: Click on Project --> Add Reference, Select "System.Web" and Click "OK".
        Dim Prefix As String = "http://TEST:3467/ldap/browse.tsp?dn="
        Dim locations As String = "CN=SerialNumber, OU=Desktops, OU=Home Office, OU=US, OU=Devices"
        Dim locations2 As String = ", DC=testdomain, DC=com"

        Dim WebString As String = Prefix & System.Web.HttpUtility.UrlEncode(locations & locations2)
        Debug.Print(WebString)

0
 

Author Closing Comment

by:chadmanvb
ID: 31502564
Thanks so much, that worked great!  Chad
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 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