Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
string manipulation in vbs or vb.net
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jesper Ravn  
View profile  
 More options Nov 9 2009, 10:57 am
Newsgroups: microsoft.public.windows.server.scripting
From: "Jesper Ravn" <jesper_r...@hotmail.com>
Date: Mon, 9 Nov 2009 11:57:49 +0100
Local: Mon, Nov 9 2009 10:57 am
Subject: string manipulation in vbs or vb.net
Hello

Im retriving users out from a security group in Active Directory.
The output is like the string below.

StrMember = "CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"

How can I clean the string, so it always will list only the username.
StrMember = "ctxadmin"

Thanks,

/Jesper


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 9 2009, 12:54 pm
Newsgroups: microsoft.public.windows.server.scripting
From: Tom Lavedas <tglba...@cox.net>
Date: Mon, 9 Nov 2009 04:54:49 -0800 (PST)
Local: Mon, Nov 9 2009 12:54 pm
Subject: Re: string manipulation in vbs or vb.net
On Nov 9, 5:57 am, "Jesper Ravn" <jesper_r...@hotmail.com> wrote:

> Hello

> Im retriving users out from a security group in Active Directory.
> The output is like the string below.

> StrMember = "CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"

> How can I clean the string, so it always will list only the username.
> StrMember = "ctxadmin"

> Thanks,

> /Jesper

Maybe ...

  StrMember =
"CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"
  strMember=Replace(Split(strMember. ",")(0), "CN=", "", -1, 1)
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesper Ravn  
View profile  
 More options Nov 9 2009, 1:37 pm
Newsgroups: microsoft.public.windows.server.scripting
From: "Jesper Ravn" <jesper_r...@hotmail.com>
Date: Mon, 9 Nov 2009 14:37:23 +0100
Local: Mon, Nov 9 2009 1:37 pm
Subject: Re: string manipulation in vbs or vb.net

"Tom Lavedas" <tglba...@cox.net> skrev i meddelelsen
news:504bfc02-1ca4-482f-a4b5-c6d8145c2526@k4g2000yqb.googlegroups.com...

Hi Tom

Thanks, for your suggestion, but the code sample fails. I also tried to
change "StrMember. " to "StrMember," without any luck.
I just ran the code in a VBScript file.

/Jesper


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Nov 9 2009, 2:04 pm
Newsgroups: microsoft.public.windows.server.scripting
From: Tom Lavedas <tglba...@cox.net>
Date: Mon, 9 Nov 2009 06:04:24 -0800 (PST)
Local: Mon, Nov 9 2009 2:04 pm
Subject: Re: string manipulation in vbs or vb.net
On Nov 9, 8:37 am, "Jesper Ravn" <jesper_r...@hotmail.com> wrote:

Sorry, I did that from memory and without testing.  There is a typo
and a missing argument (which you could have researched), but the
concept is valid.  Try this ..

  strMember = Replace(Split(strMember, ",")(0), "CN=", "", 1, -1, 1)

_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesper Ravn  
View profile  
 More options Nov 9 2009, 2:19 pm
Newsgroups: microsoft.public.windows.server.scripting
From: "Jesper Ravn" <jesper_r...@hotmail.com>
Date: Mon, 9 Nov 2009 15:19:59 +0100
Local: Mon, Nov 9 2009 2:19 pm
Subject: Re: string manipulation in vbs or vb.net

"Tom Lavedas" <tglba...@cox.net> skrev i meddelelsen
news:a59ec48a-62f6-49dc-8ec4-3524222d1c5f@l2g2000yqd.googlegroups.com...

> Sorry, I did that from memory and without testing.  There is a typo
> and a missing argument (which you could have researched), but the
> concept is valid.  Try this ..

>  strMember = Replace(Split(strMember, ",")(0), "CN=", "", 1, -1, 1)

Hi Tom

Great, it's working now. Thanks a lot.

/Jesper


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Mueller [MVP]  
View profile  
 More options Nov 9 2009, 2:36 pm
Newsgroups: microsoft.public.windows.server.scripting
From: "Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net>
Date: Mon, 9 Nov 2009 08:36:58 -0600
Local: Mon, Nov 9 2009 2:36 pm
Subject: Re: string manipulation in vbs or vb.net

"Jesper Ravn" <jesper_r...@hotmail.com> wrote in message

news:OIzU6eUYKHA.3888@TK2MSFTNGP06.phx.gbl...

> "Tom Lavedas" <tglba...@cox.net> skrev i meddelelsen
> news:a59ec48a-62f6-49dc-8ec4-3524222d1c5f@l2g2000yqd.googlegroups.com...
>> Sorry, I did that from memory and without testing.  There is a typo
>> and a missing argument (which you could have researched), but the
>> concept is valid.  Try this ..

>>  strMember = Replace(Split(strMember, ",")(0), "CN=", "", 1, -1, 1)

> Hi Tom

> Great, it's working now. Thanks a lot.

> /Jesper

However, note that the result is the "Common Name" of the user, not what
most people call the username, unless the two values have been made always
the same in your environment.

The value of the "cn" attribute is the Common Name of the object. It must be
unique in the OU, but there can be several objects with the same Common Name
as long as they are in different OU's or containers. The value of the
sAMAccountName attribute is the "pre-Windows 2000 logon name" (on the
"Account" tab of ADUC). This is also referred to as the userID, username, or
NT name of the user. This must be unique in the domain.

If the cn and sAMAccountName attributes are always the same in your domain,
you can parse the Distinguished Name of the user. Otherwise, you should use
the NameTranslate object to convert the Distinguished Name into the
sAMAccountName. See this link for details:

http://www.rlmueller.net/NameTranslateFAQ.htm

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesper Ravn  
View profile  
 More options Nov 9 2009, 3:01 pm
Newsgroups: microsoft.public.windows.server.scripting
From: "Jesper Ravn" <jesper_r...@hotmail.com>
Date: Mon, 9 Nov 2009 16:01:27 +0100
Local: Mon, Nov 9 2009 3:01 pm
Subject: Re: string manipulation in vbs or vb.net

"Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net> skrev i
meddelelsen news:#pS2ZoUYKHA.3504@TK2MSFTNGP05.phx.gbl...

Hi Richard

Thanks for the heads up. I will take a look at your great FAQ ressource.

/Jesper


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Mueller [MVP]  
View profile  
 More options Nov 9 2009, 4:06 pm
Newsgroups: microsoft.public.windows.server.scripting
From: "Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net>
Date: Mon, 9 Nov 2009 10:06:42 -0600
Local: Mon, Nov 9 2009 4:06 pm
Subject: Re: string manipulation in vbs or vb.net

"Jesper Ravn" <jesper_r...@hotmail.com> wrote in message

news:O7xtF2UYKHA.3720@TK2MSFTNGP02.phx.gbl...

A quick example converting a DN into sAMAccountName:
========
Option Explicit

Dim strUserDN, objTrans, strUserName

' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

' Specify user Distinguished Name.
strUserDN = "CN=ctxadmin,OU=ITservices,OU=RootDomain,DC=company,DC=com"

' Use the NameTranslate object to convert Distinguished Name
' into sAMAccountName.
Set objTrans = CreateObject("NameTranslate")

' Initialize NameTranslate by locating the Global Catalog.
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Use the Set method to specify the Distinguished Name of the object.
objTrans.Set ADS_NAME_TYPE_1779, strUserDN
' Use the Get method to retrieve the NT format of the name.
' This format is <NetBIOS-Domain-Name>\<sAMAccountName>
strUserName = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove NetBIOS name of domain.
strUserName = Mid(strUserName, InStr(strUserName, "\") + 1)

Wscript.Echo strUserName

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesper Ravn  
View profile  
 More options Nov 10 2009, 11:54 am
Newsgroups: microsoft.public.windows.server.scripting
From: "Jesper Ravn" <jesper_r...@hotmail.com>
Date: Tue, 10 Nov 2009 12:54:29 +0100
Local: Tues, Nov 10 2009 11:54 am
Subject: Re: string manipulation in vbs or vb.net

"Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net> skrev i
meddelelsen news:ebVrnaVYKHA.4360@TK2MSFTNGP04.phx.gbl...

Hi Richard

Nice, thanks for all your help.

/Jesper


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google