|
-
Dec 4th, 2007, 08:17 AM
#1
Showing Windows Authentication Screen
Hi all,
How can I show the windows authentication screen thorugh vb coding ?. Is it possible ?
Dana
Please mark you thread resolved using the Thread Tools as shown
-
Dec 4th, 2007, 08:51 AM
#2
Re: Showing Windows Authentication Screen
Are you talking about the Windows login screen?
If so, that will be displayed only after someone is logged out and someone else wants to log in.
You could replicate it with your own VB form though.
Why do you need to display this?
-
Dec 4th, 2007, 08:54 AM
#3
Re: Showing Windows Authentication Screen
I dont think its the logon screen but maybe the activation screen? Or perhaps the About form?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 4th, 2007, 11:17 PM
#4
Re: Showing Windows Authentication Screen
Thanks Rob and Hack 
Basically the need is , I want to map a network drive. If the user has access to that
site then that path will map automatically. If the user doesnt have any rights
the i need to get the username and pwd from the user by using windows authentication screen. Is it possible.
Dana
Please mark you thread resolved using the Thread Tools as shown
-
Dec 4th, 2007, 11:34 PM
#5
Fanatic Member
Re: Showing Windows Authentication Screen
Dana,Make use of API.
There is an API to connect the network drive,wnetaddconnection2.
Code:
Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
I think this will be useful for u,
If this connection fails means u can display the login form..
Try this, a sample below..
Code:
Private Sub Command14_Click()
Dim l As Long, username As String, userpassword As String, result As Long
theNetResource.lpRemoteName = "XXXXXXXX"
theNetResource.lpLocalName = "X:"
username = "xxxxxxx"
userpassword = "xxxxxxx"
theNetResource.dwType = RESOURCETYPE_DISK
result = WNetAddConnection2(theNetResource, userpassword, username, 0)
End Sub
Last edited by vijy; Dec 4th, 2007 at 11:40 PM.
Visual Studio.net 2010
If this post is useful, rate it

-
Dec 4th, 2007, 11:40 PM
#6
Re: Showing Windows Authentication Screen
Thanks for the info Vijy,
But How to check whether the user has rights to the particular server.If the user has the rights
it should be automatically mapped else, I have to get show the authentication screen of windows and get the password ?
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 12:04 AM
#7
Fanatic Member
Re: Showing Windows Authentication Screen
Are u maintaining any database for those user who haing rights??
Dana, in Mycomputer-> manage-> groups u will have the details about what all the rights u having in ur local.
Like this u can trap the server to see who all the users having rights and those details..
From that information u can match the user name.But for this u have the admin rights for the server.
Visual Studio.net 2010
If this post is useful, rate it

-
Dec 5th, 2007, 12:18 AM
#8
Re: Showing Windows Authentication Screen
Yes. I can able to get the username from the current computer and verify that name in the server. But How to show the
Dialog box.That is the main question.Is there any Api avalible.I found that WNetConnectionDialog show the mapnetwork dialog.
Like that is there any api ? For example if you open an IE explorer and type the servername which you dont have access
you will be shown a dialog box for getting the Username and pwd ?
Dana
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 12:32 AM
#9
Fanatic Member
Re: Showing Windows Authentication Screen
whats the title of the dialoq box
Visual Studio.net 2010
If this post is useful, rate it

-
Dec 5th, 2007, 01:00 AM
#10
Re: Showing Windows Authentication Screen
The titile of the dialog box is "Connect to XXXXX"
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 01:01 AM
#11
Fanatic Member
Re: Showing Windows Authentication Screen
Display Properties dialog box Resources on TechRepublic
i think this might be useful for u..
here
Visual Studio.net 2010
If this post is useful, rate it

-
Dec 5th, 2007, 01:31 AM
#12
Re: Showing Windows Authentication Screen
Some good infos.But Not I wanted
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 04:08 AM
#13
Re: Showing Windows Authentication Screen
Yes I found it 
Code:
ErrInfo = WNetAddConnection2(NetR, MyPass, MyUser, _
CONNECT_INTERACTIVE Or CONNECT_PROMPT)
MSDN
Last edited by danasegarane; Dec 5th, 2007 at 05:00 AM.
Reason: MSDN Link Added
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 04:21 AM
#14
Fanatic Member
Re: Showing Windows Authentication Screen
Visual Studio.net 2010
If this post is useful, rate it

-
Dec 5th, 2007, 08:02 AM
#15
Re: Showing Windows Authentication Screen
But Now I am facing one problem.Even If i have permision to that server it still prompting for username and password .I dont wy.Can some one help ?
Dana
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 08:05 AM
#16
Re: Showing Windows Authentication Screen
Oh so you wanted to show a logon form for authentication to other resources. Are you passing the correct server name \ username so that the credientials are per domain vs per machine? Also, are you passing credientials that have permissions to the resource?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 5th, 2007, 08:05 AM
#17
Re: Showing Windows Authentication Screen
The code I am using is
vb Code:
Option Explicit
Private m_WindowsUserName As String
Private m_NetworkPath As String
Private ErrInfo As Long
'Initialization of Varraibles
'Private Sub Class_Initialize()
' MapDrive
'End Sub
Private Function MapDrive()
Dim NetR As NETRESOURCE
Dim MyPass As String, MyUser As String
NetR.dwScope = RESOURCE_GLOBALNET
NetR.dwType = RESOURCETYPE_DISK
NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
NetR.lpLocalName = "X:" ' If undefined, Connect with no device
NetR.lpRemoteName = m_NetworkPath ' Your valid share
' If the MyPass and MyUser arguments are null (use vbNullString), the
' user context for the process provides the default user name.
ErrInfo = WNetAddConnection2(NetR, MyPass, MyUser, _
CONNECT_INTERACTIVE Or CONNECT_PROMPT)
'CONNECT_INTERACTIVE )
If ErrInfo = NO_ERROR Then
MsgBox "Net Connection Successful!", vbExclamation, "Share Connected"
Else
MsgBox GetErrorInfo, vbExclamation, "Share Not Connected"
End If
End Function
'Function get the Error description using Error Id
Private Function GetErrorInfo() As String
If ErrInfo = NO_ERROR Then
'If no Error do nothing
ElseIf ErrInfo = ERROR_CANCELLED Then
GetErrorInfo = "User Cancelled !"
ElseIf ErrInfo = ERROR_NO_NET_OR_BAD_PATH Then
GetErrorInfo = "Network Not Found !"
ElseIf ErrInfo = ERROR_NO_NETWORK Then
GetErrorInfo = "Network Not Found !"
ElseIf ErrInfo = ERROR_DEVICE_ALREADY_REMEMBERED Then
GetErrorInfo = "The Network is Already Connect. Please disconnect it and try again !"
Else
GetErrorInfo = ErrInfo & " - Net Connection Failed!"
End If
If Len(GetErrorInfo) > 0 Then
GetErrorInfo = "ERROR : " & GetErrorInfo
End If
End Function
Public Property Get NetWorkPath() As String
NetWorkPath = m_NetworkPath
End Property
Public Property Let NetWorkPath(ByVal vNewValue As String)
m_NetworkPath = vNewValue
End Property
Public Function MapRemoteDrive()
MapDrive
End Function
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 08:07 AM
#18
Re: Showing Windows Authentication Screen
Yes Mr.Rob. I am passing the correct servername only.I have posted the code there
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 08:48 AM
#19
Re: Showing Windows Authentication Screen
Dear Rob and Hack,
I want to use the default username and password to map the drive.If it doesnt match, it has to dispay the
authentication window.Is this correct ?
PHP Code:
ErrInfo = WNetAddConnection2(NetR, [COLOR="Blue"]VBNullstring, VBNullstring,[/COLOR] _
CONNECT_INTERACTIVE Or CONNECT_PROMPT)
Please mark you thread resolved using the Thread Tools as shown
-
Dec 5th, 2007, 09:30 AM
#20
Re: Showing Windows Authentication Screen
Looks ok but what its the return value?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 5th, 2007, 11:45 PM
#21
Re: Showing Windows Authentication Screen
Dear Rob,
Actually when type the server name from the run command it open in the explorer.But If i open the same server then it is prompting the authentication dialog box ? .What could be reason ?

Dana
Please mark you thread resolved using the Thread Tools as shown
-
Dec 6th, 2007, 04:01 AM
#22
Re: Showing Windows Authentication Screen
What if you take the CONNECT_PROMPT out?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 6th, 2007, 04:10 AM
#23
Re: Showing Windows Authentication Screen
I tried this code
Code:
Private Function MapDrive()
Dim NetR As NETRESOURCE
Dim MyPass As String, MyUser As String
MyUser = GetWindowsUsername
NetR.dwScope = RESOURCE_GLOBALNET
NetR.dwType = RESOURCETYPE_DISK
NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
NetR.lpLocalName = "X:" ' If undefined, Connect with no device
NetR.lpRemoteName = m_NetworkPath ' Your valid share
' If the MyPass and MyUser arguments are null (use vbNullString), the
' user context for the process provides the default user name.
' ErrInfo = WNetAddConnection2(NetR, MyPass, MyUser, _
' CONNECT_INTERACTIVE Or CONNECT_PROMPT)
'CONNECT_INTERACTIVE )
' ErrInfo = WNetAddConnection2(NetR, vbNullString, vbNullString, _
' CONNECT_INTERACTIVE Or CONNECT_PROMPT)
' MyUser = GetWindowsUsername
ErrInfo = WNetAddConnection2(NetR, vbNullString, vbNullString, _
CONNECT_INTERACTIVE)
MsgBox "Return value" & ErrInfo
If ErrInfo = NO_ERROR Then
MsgBox "Net Connection Successful!", vbExclamation, "Share Connected"
Else
MsgBox GetErrorInfo, vbExclamation, "Share Not Connected"
End If
End Function
It returned the value 0 for one server which I have rights
And also 0 for the one Which I dont Have rights.But When I click that mapped drive,it is giving error msg that ACCESS DENIED
-
Dec 6th, 2007, 04:18 AM
#24
Re: Showing Windows Authentication Screen
Instead of relying on the return value try using the GetLastError API call to get more detailed return value. It may show something different. If you dont have permissions then it should return ERROR_ACCESS_DENIED
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 6th, 2007, 04:30 AM
#25
Re: Showing Windows Authentication Screen
It Returns the values as "The Operation Complelted Successfully" and then I tryied to click the Drive, giving msg that Access is denied ?
-
Dec 12th, 2007, 04:31 AM
#26
Re: Showing Windows Authentication Screen
Hmm, not sure what else it could be other then it not retaining the username/password or its using a different set.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|