Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

Hi folks,

An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).

The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Environ("username")

Give the windows API a whirl...

Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long

Function GetUser() As String
Dim Ret As Long
Dim UserName As String
Dim Buffer As String * 25
Ret = GetUserName(Buffer, 25)
UserName = Left$(Buffer, InStr(Buffer, Chr(0)) - 1)
GetUser = UserName
End Function

Sub test()
MsgBox GetUser
End Sub
--
HTH...

Jim Thomlinson


"riso" wrote:

Hi folks,

An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).

The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?

thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

Hi,

I am sorry, Test() shows the same 'weakuser' as Environ("username").

thanks for your effort.

other solution?

riso

On Mar 6, 9:17 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Give the windows API a whirl...

Private Declare Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long

Function GetUser() As String
Dim Ret As Long
Dim UserName As String
Dim Buffer As String * 25
Ret = GetUserName(Buffer, 25)
UserName = Left$(Buffer, InStr(Buffer, Chr(0)) - 1)
GetUser = UserName
End Function

Sub test()
MsgBox GetUser
End Sub
--
HTH...

Jim Thomlinson



"riso" wrote:
Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Environ("username")

Have you logged off of those machines and logged back on since?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"riso" wrote in message
ups.com...
Hi folks,

An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).

The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?

thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

Yes.

Environ("username") returns 'weakuser' for weeks. Users' computers are
turned off daily.

thanks


On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"riso" wrote in message

ups.com...



Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Environ("username")

Sounds like the Accounts' usernames were not changed "correctly" somehow.
Works for me with just log-off/on; correctly username is returned.
Are you sure the usernames were actually changed ?

NickHK

"riso" wrote in message
oups.com...
Yes.

Environ("username") returns 'weakuser' for weeks. Users' computers are
turned off daily.

thanks


On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"riso" wrote in message

ups.com...



Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

I forgot .....

The same behaviour you can observe if you create an account as a XP
windows administrator with the name 'User1' and later rename that
account to User2 (via standart tools of XP windows administrator).

Environ("username") always returns User1 not User2.

I have seen a discusion similar to this one about .net
System.Environment.UserName (http://www.mcse.ms/message1250010.html).

The solution was to check the other properties of AD e.g. displayname,
CN, SN, givenName, userPrincipalName (sAMAccountName is the attribute
in AD that is the "username" used for logins
and such)

But I do not know how to utilise that solution in excel VBA.

riso

On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"riso" wrote in message

ups.com...



Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

Thank for your answer.

I have tried it myself. I logged on as XP windows administrator and
changed account name from weakuser to testuser.

In the login screen (that one with pictures and account names) is
written "administrator" and "testuser". When logged as testuser I have
started excel and try msgbox Environ("username"). It shows "weakuser".

Moreover. I have thought that it is related to usage of imagedisk. I
have created completely new account "user1", logged in, runned excel
and msgbox. It showed user1. logged off, logged in as administrator,
changed account name to user2, logged off, restarted computer, logged
in as user2 (it was showed in the login screen), runned excel and
msgbox. It shows user1. Still original account name.

Maybe it is related to corrupted XP windows, but I doubt.



On Mar 8, 9:23 am, "NickHK" wrote:
Sounds like the Accounts' usernames were not changed "correctly" somehow.
Works for me with just log-off/on; correctly username is returned.
Are you sure the usernames were actually changed ?

NickHK

"riso" wrote in message

oups.com...



Yes.


Environ("username") returns 'weakuser' for weeks. Users' computers are
turned off daily.


thanks


On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?


--
---
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"riso" wrote in message


oups.com...


Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

I have checked also user directories for these accounts.

C:\Documents and Settings\admin .... for user with administrator right
C:\Documents and Settings\weekuser .... for user Smith (his login name
is Smith)
C:\Documents and Settings\user1 ..... for user User2


Is something wrong with instalation of XP Windows?

thanks



On Mar 8, 9:45 am, "riso" wrote:
Thank for your answer.

I have tried it myself. I logged on as XP windows administrator and
changed account name from weakuser to testuser.

In the login screen (that one with pictures and account names) is
written "administrator" and "testuser". When logged as testuser I have
started excel and try msgbox Environ("username"). It shows "weakuser".

Moreover. I have thought that it is related to usage of imagedisk. I
have created completely new account "user1", logged in, runned excel
and msgbox. It showed user1. logged off, logged in as administrator,
changed account name to user2, logged off, restarted computer, logged
in as user2 (it was showed in the login screen), runned excel and
msgbox. It shows user1. Still original account name.

Maybe it is related to corrupted XP windows, but I doubt.

On Mar 8, 9:23 am, "NickHK" wrote:



Sounds like the Accounts' usernames were not changed "correctly" somehow.
Works for me with just log-off/on; correctly username is returned.
Are you sure the usernames were actually changed ?


NickHK


"riso" wrote in message


roups.com...


Yes.


Environ("username") returns 'weakuser' for weeks. Users' computers are
turned off daily.


thanks


On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?


--
---
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my

addy)


"riso" wrote in message


oups.com...


Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Environ("username")

So you are talking about Active Directory ?

You example ("User1""User2") give the correct result on W2K, local account.

Could not locate the server in the link you provided, so no idea that
context.

NickHK

"riso" wrote in message
s.com...
I forgot .....

The same behaviour you can observe if you create an account as a XP
windows administrator with the name 'User1' and later rename that
account to User2 (via standart tools of XP windows administrator).

Environ("username") always returns User1 not User2.

I have seen a discusion similar to this one about .net
System.Environment.UserName (http://www.mcse.ms/message1250010.html).

The solution was to check the other properties of AD e.g. displayname,
CN, SN, givenName, userPrincipalName (sAMAccountName is the attribute
in AD that is the "username" used for logins
and such)

But I do not know how to utilise that solution in excel VBA.

riso

On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"riso" wrote in message

ups.com...



Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

That's crazy, that page was available just yesterday.

try google site:site:mcse.ms/message1250010.html and see cached data.
Here is a direct link.

<http://209.85.129.104/search?q=cache...J:www.mcse.ms/
message1250010.html+site:mcse.ms/message1250010.html&hl=en&strip=1

I am not sure if the topic "Wrong Username with
System.Environment.UserName" described as "Wrong Username with
System.Environment.UserName .NET Security." is really related to my
problem with excel VBA environ("username"). But the symptoms are the
same.

riso

On Mar 8, 9:56 am, "NickHK" wrote:
So you are talking about Active Directory ?

You example ("User1""User2") give the correct result on W2K, local account.

Could not locate the server in the link you provided, so no idea that
context.

NickHK

"riso" wrote in message

s.com...



I forgot .....


The same behaviour you can observe if you create an account as a XP
windows administrator with the name 'User1' and later rename that
account to User2 (via standart tools of XP windows administrator).


Environ("username") always returns User1 not User2.


I have seen a discusion similar to this one about .net
System.Environment.UserName (http://www.mcse.ms/message1250010.html).


The solution was to check the other properties of AD e.g. displayname,
CN, SN, givenName, userPrincipalName (sAMAccountName is the attribute
in AD that is the "username" used for logins
and such)


But I do not know how to utilise that solution in excel VBA.


riso


On Mar 6, 10:22 pm, "Bob Phillips" wrote:
Have you logged off of those machines and logged back on since?


--
---
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my

addy)

"riso" wrote in message


oups.com...


Hi folks,


An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).


The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?


thanks- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Environ("username")

Maybe it is worth to add that system is Windows XP Home Edition SP2
czech version.
Could this problem be related only to the local versions (czech)?


Who knows? Not me. Bill? What about you, Bill?


On Mar 6, 9:06 pm, "riso" wrote:
Hi folks,

An IT administrator 'created' 10 PC with windows XP with 2 users,
namely "administrator" and "weakuser", with an imagedisc. Later
administrator logged in to every computer and changed the account name
of the user from 'weakuser' to the real name of a person who uses that
computer (e.g. Smith, Shepard, etc).

The interesting thing is that Environ("username") on every PC returns
'weakuser', not the real name. Is it possible to find the login (Smith
or Shepard or etc.) in VBA?

thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"filename is locked for editing by username" srinath Excel Discussion (Misc queries) 1 February 26th 09 11:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Including Environ Username in Cell swieduwi Excel Worksheet Functions 9 March 30th 06 04:43 PM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"