'+********************************************************************************************
'*
'* Function: MMC_GetNTuserName
'*
'* Author: FancyPrairie
'*
'* Date: 7/19/2002
'*
'* Purpose: Returns the user's NT logon name or "!!Error!!" if failed to get NT name
'*
'* Call: strUserName = GetNTuserName
'*
'-********************************************************************************************
Function GetNTuserName()
dim strUserName
Dim objNet
On Error Resume Next 'In case we fail to create object then display our custom error
Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then 'If error occured then display notice
msgbox "Your security settings for the Intranet site are preventing this form from operating correctly." & vbcrlf & vbcrlf & "To fix the problem, goto Tools|Internet Options|Security and select the Local INTRANET icon. Then select the button labeled ""Customize Level..."" (located at the bottom of the window)." & vbcrlf & vbcrlf & "The option entitled ""Initialize and script ActiveX controls not marked as save"" MUST NOT be disabled. Likewise, ""Run ActivX controls and plug ins"" must also NOT be disabled.",vbexclamation
Set objNet = Nothing 'Destroy the Object to free the Memory
GetNTuserName = "!!Error!!"
Else
strUserName = objNet.UserName
Set objNet = Nothing 'Destroy the Object to free the Memory
GetNTuserName = strUserName
End if
End Function