I had been stuck with the problem and research for it for few days but to no avail.
I'm working on a c# project and my program will automactically read the username from the user's windows whenever the user try to access the web application through the internet.
I tried with the following commands below and it works when I'm debugging the program/ running from localhost in the server. It managed to grab my username from windows and appear on the application.
(HttpContext.Current.User.Identity.Name);
(System.Environment.UserName);
(WindowsIdentity.GetCurrent().Name);
(Page.User.Identity.Name);
(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
However, they did not work when I publish it and tried to access them from the web.
Instead, it gives me the following ID which I suspect is from the IIS7/ windows server 2008 that I host my site at. Rather than giving me the username from the user's console.
-there is no value-
-it gives me my server name
NTAUTHORITY\NETWORKSERVICE
-there is no value-
NTAUTHORITY\NETWORKSERVICE
May I know what went wrong in this case?
Another thing, through my research, I learnt how to get the username/ userdomain through the cmd.exe with commands below.
echo %username%
set username
wmic useraccount where name=%username% get name
wmic useraccount where name=%username% get sid
whoami
whoami/user
May I know if it's possible to apply these commands in windows visual studio for me to read the username from the user'windows when they access my webpage?
So, I hope I can get some advice from the users from this community. Thank you!
I solved the problem already.
Problem lies in the IIS. I checked against the authentication method and turned off everything except windows. From there, I checked against the web.config and ensure that the is turned to "false".
I also used HttpContext.Current.User.Identity.Name to get the username from the user's console.
Related
Im having trouble with writing files to remote directory via network. The following code fails when I try to check if the directory exists:
if (!Directory.Exists(processingPath))
Directory.CreateDirectory(processingPath);
processingPath is composed like
processingPath = xxxObject.serverPath + "processing\\";
xxxObject.serverPath contains something like this
\\machineNetworkName\sharedFolder\
Its working properly, but when many requests are processing (running as tasks asynchronously), it stops working and failing into exception:
System.IO.IOException: The network path was not found.
Could you please help me what could be the problem and why it is failing after some time on network path???
Thanks for your solutions
I got the same error before, it was about authentication problems.
You have to be sure that you set properly the user on IIS, because it use a Default App Pool's identity which can't access to your NFS.
You can also use IIS virtual folders to set the identity.
(on IIS manager, see App Pool settings -> Identity and also virtual folders settings -> identity).
In my case, it worked better by using the Impersonation directly in the code, so I recommend you to use the VladL WrappedImpersonationContext Object: How to provide user name and password when connecting to a network share
Last thing to check, the owner of the files on your NFS server, if they were created under the root user, it might not work.
I had the same problem and solved it. The problem in my code and I see it in yours, too, is that you have the slash at the end of the network path.
Instead of processingPath = xxxObject.serverPath + "processing\\"; write: processingPath = xxxObject.serverPath + "processing";
I stumbled upon MantisBT recently and got it set up at my workplace for future bug tracking. I wanted to make a neat little library we can use in our applications so that users can report bugs to us directly from the application in question.
Currently in a sandbox application I made to try and understand MantisConnect. I consumed the webservice successfully and I can make a client. But if I try and do this:
MantisConnectPortTypeClient client = new MantisConnectPortTypeClient();
UserData usrData = client.mc_login("omitted", "omitted");
I get a FaultException and the message "Access Denied"
Currently running Mantis 1.3.rc-dev.02
Any ideas on why this simple call is denied? It doesn't matter what user I use. It gets denied regardless.
Okay I figured it out.
The WSDL file on the server was still pointing to mantisbt.org instead of our local server. Changed it to our local server address and it worked fine.
HI I want to create an ios application in visual studio using xamarin.
But After creating project it is asking us to connect to mac.
Which Credentials it is asking for and how to find it.
I think you are making use of Xamarin.VS Build Host Application
Refer :
https://developer.xamarin.com/guides/ios/getting_started/installation/windows/xamarin-mac-agent/#Windows_Setup
https://msdn.microsoft.com/en-us/library/mt299001.aspx?f=255&MSPPError=-2147217396#AddiOS
Are you tired of getting the below error on pairing to mac from a windows system
Invalid credentials. Please try again
Never thought that pairing to mac from a windows system would be this simple!
Username : Name displayed while you log-in to open your Mac system
Password : Password you enter to log-in for the above username displayed
Still not sure?
Choose System Preferences from the Apple menu, then click Users & Groups.
You can see user name as Current User Reference : https://support.apple.com/en-in/HT202860
To know the Mac IP address, check manually add a mac from https://learn.microsoft.com/en-gb/xamarin/ios/get-started/installation/windows/connecting-to-mac/#manually-add-a-mac
Detailed reference : https://learn.microsoft.com/en-gb/xamarin/ios/get-started/installation/windows/connecting-to-mac/
its very irritating, i found a code sample to get username from stackoverflow on how to get under which username a process running and its working fine in console app but not working in windows service. returnVal is 2 and not showing username and domain. Can anyone tell me do i need to change any setting in windows service.
Try running the service under an account that has enough privileges to call GetOwner().
I believe that what you're after is simply:
string user = Environment.UserName;
The service itself is running using some system account but you said you're looking for your own account name, meaning the logged in user account.
I am working on development machine without making any user account [i have three of four account who comes when i installed them].
so i open the connection everywhere by a globals variable who hold the connectionstring off-course value of variable can not be changed it's constant.
i open the connection using root account who come by default in mysql server. they work fine everywhere.
but my code try to run a command then server return the error that
The user specified as a definer ('admin'#'localhost') does not exist
i don't know why i got this error even in debug i found that connection open by root and they work fine everywhere else.
so the problem is why they tell me about admin#localhost even the connection my code open by root.
are their anything my code try to do who need authentication or need admin account even they not have then give me exception.
Are you know that what is gone wrong.
I got this error after DB was moved to another server.
There no such user 'admin' so I got the error.
Solution:
log into mysql as root
grant all on *.* to admin#localhost identified by "s!5_superp#ss!";
flush privileges;