Solved

Loop to fill in a string

Posted on 2008-10-02
6
294 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 300 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
Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

 

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 200 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

635 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