Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Obtain user login name
 

Obtain user login name

I've been creating an application using Visual Studio standard edition.
I'm now looking into user permissions based on user login.
I have a SQL database with all the users.
My question is how do I detect or obtain the user login name?
jacobsdesigns  Thursday, August 06, 2009 10:57 PM
Hi,

Dear elaborate the question , what is ur requirementwhich one user you want to dected windows login credetial, sql regiserted useror want to detect user login thatare save ina custom user table on Sql server.

if you want to capture the windows login user use the following code, and save the login user name into a static variable that is having application scope.

WindowsIdentity wi = WindowsIdentity.GetCurrent();
bool IsAuthenticated = wi.IsAuthenticated;
string LoginUserName = wi.Name.ToUpper();

u can could the following code also to get user
string strUser = Environment.UserName;

In other case if your login persmission save into dateTable on Sql Server , just authenticate the login user into database table if it is authenticated and then same the current user into a static variable.

Good Luck.


Malik M.Shahid  Friday, August 07, 2009 1:38 PM
Hi,

Dear elaborate the question , what is ur requirementwhich one user you want to dected windows login credetial, sql regiserted useror want to detect user login thatare save ina custom user table on Sql server.

if you want to capture the windows login user use the following code, and save the login user name into a static variable that is having application scope.

WindowsIdentity wi = WindowsIdentity.GetCurrent();
bool IsAuthenticated = wi.IsAuthenticated;
string LoginUserName = wi.Name.ToUpper();

u can could the following code also to get user
string strUser = Environment.UserName;

In other case if your login persmission save into dateTable on Sql Server , just authenticate the login user into database table if it is authenticated and then same the current user into a static variable.

Good Luck.


Malik M.Shahid  Friday, August 07, 2009 1:38 PM

You can use google to search for other answers

Custom Search

More Threads

• MaskedTextbox problem when 1st digit enter
• Changes at InitializeComponent()
• How can I make a form listen to mouse_move event at design-time?
• Form Localization Issues Exception
• How to code while pressing the Ctrl+Tab Key in Windows Form?
• Question about a Design time component!
• System.Windows.Forms.Message - Doubt
• adding an item to the top of the listview control in vb.net
• this really doesnt apply to the design section but im asking for help with this problem everywhere;
• Implementing IButtonControl