By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,490 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,490 IT Pros & Developers. It's quick & easy.

apiGetUserName function

MMcCarthy
Expert Mod 10K+
P: 14,534
guys does this get the user name from the active directory and if so how can we make sure we get the user profile name instead of the network login name.

Problem is machines have been reimaged with JoinAD installed which automatically logs on to internet sites and sharepoint. Each user has a unique ID called a T-Number (Format XX####) with their login name which is made up of surname.firstinitial Access won't allow this so how can we use the T-Number instead.

Mary
Oct 8 '08 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,709
Not sure exactly what you're after here, but there are two approaches that may yield something workable.
  1. In the environment variables there should be one called UserProfile. Referring to the actual profile name within that (It's a path) can be done as :
    Expand|Select|Wrap|Line Numbers
    1. Dim intIx As Integer
    2.  
    3. intIx = UBound(Split(Environ("USERPROFILE"),"\"))
    4. Debug.Print Split(Environ("USERPROFILE"),"\")(intIx)
    Or, in a single line refer to :
    Expand|Select|Wrap|Line Numbers
    1. Split(Environ("USERPROFILE"),"\")(UBound(Split(Environ("USERPROFILE"),"\")))
  2. An alternative, is to strip any invalid characters out of the value you're using. My user names are all in the format First.Last. I simply use :
    Expand|Select|Wrap|Line Numbers
    1. Replace(UserID, ".", "")
Oct 8 '08 #2

NeoPa
Expert Mod 15k+
P: 31,709
guys does this get the user name from the active directory and if so how can we make sure we get the user profile name instead of the network login name.
Yes, it does I believe, get the actual network account name.
Oct 8 '08 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
I found it. Got it by using .....

Expand|Select|Wrap|Line Numbers
  1. Environ("USERID")
Thanks for the direction though :D
Oct 8 '08 #4

NeoPa
Expert Mod 15k+
P: 31,709
:S USERID is not a generally available environment variable.

USERNAME is, but that would simply reflect the logged on account.

Remember also, that all of these environment variables are cheatable by a user changing them.
Thanks for the direction though :D
Always a pleasure :)
Oct 9 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.