apiGetUserName function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #1

    apiGetUserName function

    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.firstin itial Access won't allow this so how can we use the T-Number instead.

    Mary
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    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 :
      Code:
      Dim intIx As Integer
      
      intIx = UBound(Split(Environ("USERPROFILE"),"\"))
      Debug.Print Split(Environ("USERPROFILE"),"\")(intIx)
      Or, in a single line refer to :
      Code:
      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 :
      Code:
      Replace(UserID, ".", "")

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Originally posted by msquared
      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.

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        I found it. Got it by using .....

        Code:
        Environ("USERID")
        Thanks for the direction though :D

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          :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.
          Originally posted by msquared
          Thanks for the direction though :D
          Always a pleasure :)

          Comment

          Working...