Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2004, 08:10 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do i retrive login name

Hi guys can you pls help me to retrive login name, sql2000 integrated with win2000 server:
i want to display it in windows form using vb.net
sample; you are logged as Drachx

 
Old October 4th, 2004, 12:44 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

you mean u want to retrive all the logins in sql2k??

Regards
Ganesh
 
Old October 4th, 2004, 02:44 AM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i mean user login, sql2000 is integrated with win2000 server for login,my account name when i log on to windows is drachx, i need to display my login name in wndows form, how can i do it?

 
Old October 4th, 2004, 03:10 AM
Authorized User
 
Join Date: Nov 2003
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Write an API function to retrieve the value from the key -

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

You can use GetUserName Lib "advapi32.dll" Alias "GetUserNameA" to get the logon username.

Lookout on calling APIs in VB.NET. Hope this helps.

 
Old October 7th, 2004, 06:48 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dim str As String
str = System.Environment.UserDomainName + "\" + System.Environment.UserName

str will Contain the Login name with the domain name.





It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 7th, 2004, 06:53 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also you can use the following code

Imports System.Security.Principal

Dim wp As WindowsPrincipal = New WindowsPrincipal(WindowsIdentity.GetCurrent())
MessageBox.Show("Your login id:" + wp.Identity.Name)





It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old October 7th, 2004, 07:35 PM
Authorized User
 
Join Date: Oct 2004
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

TNX PRADEEP

code works, really appreciate it






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to retrive image from database gaurav gupta ASP.NET 2.0 Professional 1 July 21st, 2008 10:44 AM
How to retrive a value from DataGrid (WebForm) jkusmanto VB.NET 2002/2003 Basics 0 June 13th, 2006 02:47 AM
retrive file extension Dj Kat Javascript How-To 2 December 10th, 2005 01:35 PM
how to retrive the column properties harshagowda Access 1 December 3rd, 2004 12:13 PM
How to retrive the computer name in ASP? jayaraj Classic ASP Professional 3 July 24th, 2004 01:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.