Link to home
Start Free TrialLog in
Avatar of GMDtech
GMDtech

asked on

Locked for editing by %wrong username%

What could be causing files to show up as locked for editing by a different user than the person who is editing the file?

For example.  If "Sharon" has a file open, and "John" tries to open it, it says that it is locked for editing by "Mike".

Also some people get a message that it is locked by the domain admin account.  But that could be a process on the server.
ASKER CERTIFIED SOLUTION
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
KCTS is correct.  To expand on this, the information is stored in the UserName string value under the registry key HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo.  

You could add a line like the one below to a logon script in order to reset everyone's Office username so that it's the same as their Windows username.  Note that the REG command wasn't included with Windows 2000 by default, so copy REG.EXE to your script folder if you have any 2000 clients.


reg add HKCU\Software\Microsoft\Office\Common\UserInfo /v UserName /t REG_SZ /d "%username%" /f

Open in new window

@Shift-3 - now that's clever - I like it :-)
Avatar of GMDtech
GMDtech

ASKER

Trying this today:
reg add HKCU\Software\Microsoft\Office\Common\UserInfo /v UserName /t REG_SZ /d "%username%" /f

They may prefer their full name though.

Thanks
Avatar of GMDtech

ASKER

I tried this script and it did not seem to work.  Also people would prefer their full name to be in the "user info" rather than their username.

What happened is that we configure computers in a certain way, and then copy the admin profile over the "default profile" so  that when a new profile is created on a computer it shows up in the "stardard" way that we use, and they are used to.   This "User Information" in word is carried over too though.

Does anyone know how to reset the user info so it prompts for name and initials?

Thanks
If you just delete the values within

HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo           (for office 2007)

HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo   (for office 2003)

Then MS Office (Excel, Word) will prompt upon next startup for that information.  You don't specify if you are using Office 2003 or 2007 but the behavior in deleting the keys in similar.  However if you are writing to the keys you should note that Office 2007 uses "String" values (aka REG_SZ) and Office 2003 uses "Binary" values (aka REG_BINARY).

If you are using Office 2003, here is a helpful script that obtains the user's full name and initials, converts them to binary, and writes the registry keys.  It's wonderful and saved me from the problem you describe.  (Note:  I did not write this script, but stumbled on it somewhere... not sure where but credit to the author).  It worked without any edits for me, so I would assume the same for you.

But I've now upgraded to Office 2007 and I'd like to have this script work for office 2007, but I don't know VB Script enough to change this.  I can of course change the reg key it writes to (easy enough) but I need the values in STING (plain text) and not HEX/BINARY.  Can anyone help?  Please?
If ANYONE reads this and can update the script and post back here I would be most appreciative!

Thanks - Justin
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
 
' get UserName
strName = oShell.ExpandEnvironmentStrings("%USERNAME%")
 
strContainer = "ou=MyOUInAD"
 
On Error Resume Next
 
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_DOMAIN = 1
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1179 = 1
 
Set objNetwork = CreateObject("Wscript.Network")
 
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
 
' Use the NameTranslate object to find the NetBIOS domain name from the
' DNS domain name.
Set objTrans = CreateObject("NameTranslate")
objTrans.Init ADS_NAME_TYPE_NT4, strDNSDomain
objTrans.Set ADS_NAME_TYPE_1179, strDNSDomain
strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4)
' Remove trailing backslash.
strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1)
 
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
objTrans.Init ADS_NAME_INITTYPE_DOMAIN, strNetBIOSDomain
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strName 
strUserDN = objTrans.Get(ADS_NAME_TYPE_1179)
 
' Bind to the user object in Active Directory with the LDAP provider.
Set objUser = GetObject("LDAP://" & strUserDN)
 
'Get Common name
strUsername= objUser.cn
 
'Convert Initials to HEX
For i = 1 to Len(strName)
 strInitialsHex = strInitialsHex & "," & Hex(Asc(Mid(strName, i, 1))) & ",00"
Next
strInitialsHex = Right(strInitialsHex , Len(strInitialsHex ) -1)
strInitialsHex = strInitialsHex & ",00,00"
 
'Convert Username to HEX
For i = 1 to Len(strUsername)
 strUsernameHex = strUsernameHex & "," & Hex(Asc(Mid(strUsername, i, 1))) & ",00"
Next
strUsernameHex = Right(strUsernameHex, Len(strUsernameHex) -1)
strUsernameHex = strUsernameHex & ",00,00"
 
' Create temporary registry file
Const OverwriteIfExist = -1
Const FailIfExist      = 0
Const OpenAsASCII   =  0
Const OpenAsUnicode = -1
Const OpenAsDefault    = -2
sTmpFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UserInfo.reg"
Set fFile = oFSO.CreateTextFile(sTmpFile, OverwriteIfExist, OpenAsASCII)
 
 
' Write to the temporary registry file
fFile.WriteLine "Windows Registry Editor Version 5.00"
fFile.WriteLine
fFile.WriteLine "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"
fFile.WriteLine """UserName""=hex:" & strUsernameHex
fFile.WriteLine """UserInitials""=hex:" & strInitialsHex 
fFile.Close
 
' Import the registry file
oShell.Run "regedit /s " & sTmpFile, 0, True
 
' Delete the temporary registry file
oFSO.DeleteFile sTmpFile

Open in new window

office-username.vbs.txt

All - I've posted a similar question to have this script updated in the VBScript forum here:

https://www.experts-exchange.com/questions/23834300/VBScript-Help-Updating-Script.html

If you are interested I would suggest following this question.
Avatar of GMDtech

ASKER

This did work.  The script never did.  So I will go with this, sorry for taking so long.