Append or Inject domain into Username when logging into sharepoint 2013 - c#

I have set up SharePoint 2013 for my organization but the users have to always enter a domain (User1#domain.com) after their username.
I have searched but i cant find any solution or even where the file for this is located. I'm wondering if i can get some help either finding where that file is or an alternate solution for this issue. Thanks!
Switching my authentication type is not really an option either, and yes I want the user to be promoted for the password every time.

On the SharePoint server I went to IIS, clicked on the local host tree then in the center console under IIS I opened up Authentication. Click basic authentication then under actions click edit. Once there I entered a default domain name and voila, like magic it now works!

So if i understand correctly here your SharePoint farm domain (e.g. sharepoint.com) and users domain (user#companyXYZ) don't have a "trust relationship?.
When you access a office document from a library as an Untrusted Client (even though your login credentials are already authenticated by the browser session cookie) when an Office Application opens, IE does not pass authentication/trust/token to the next application to gain the same access that is already trusted with IE. The additional log-in prompts is because the documents opened with Office are trying to re-establish a trust per application, because the client machine is not trusted from a public web and a new authentication is requested.
May want to review : Authentication prompts when opening Microsoft Office documents
If you can provide a fiddler trace of an authentication and identify if you are using "classic" or "claims" i can help more.

Related

ASP.NET MVC Windows Authentication is displaying login prompt instead of logging me in

Based on this article I've created a basic ASP.NET MVC site using the Visual Studio 2013 Intranet Site template with the default settings and changing nothing.
When running the site in debug mode instead of logging me in and displaying my domain\username, I am getting prompted to enter my username/password in a Authentication Required dialog.
I was under the impression, since I am already authenticated against the domain, I should be logged straight into the application using my AD account without having to enter in anything. When I do try explicitly entering my AD name or a local user account, nothing is accepted.
EDIT
If I type in my username/password with Firefox I am authenticated, but not with Chrome and IE.
Any ideas?
What you're encountering is something that's frustrated me about windows authentication for a long time. Internet explorer has a feature called pass-through authentication that authenticates you automatically when using windows auth. Other browsers have work arounds: https://addons.mozilla.org/en-US/firefox/addon/integrated-auth-for-firefox/ .
It's up to the sys admins to implement those measures for the other browsers, but nobody ever does, so we get stuck typing in our full usernames and passwords in every browser but IE.
What you can do is follow this approach : http://blogs.msdn.com/b/chunliu/archive/2010/09/21/creating-a-custom-login-page-for-windows-authentication.aspx
Not nearly as simple as enabling windows auth, or even implementing forms auth for that matter, but consider a scenario where you want infrastructure to manage permissions and administer user accounts, or if you want to expose your login page globally without exposing AD.
IE won't pass credentials to a site unless it's in the intranet security zone or the same domain. You can add your site to IE's list of trusted sites using
Internet Options > Security > Trusted sites > Sites
Chrome takes its trusted site settings from IE's settings, so once you add to IE, it should also work in Chrome
Check with your IIS (Internet Information Server) Manager and see if your application has the right permissions for the user.
Go to the "Connections" panel on the left-hand side
Under "Sites", navigate to your application or folder holding the application
Right click and select "Edit Permissions..."
Go to the "Security" tab
Check if your Windows ID or Windows Group (if multiple users) have the correct permissions to this site under the "Group or user names" box
If the user or group is not there, click on the "Edit" button and then click the "Add" button
Also check if "Windows Authentication" is enabled and both "Anonymous Authentication" and "ASP.NET Impersonation" are disabled for the application on the IIS.

Authenticating user trying to access TFS2010 through webform on remote server

I have made a webform that inserts work items to a tfs 2010server. On the tfs server I need to be able to see which user created the work item. If I run the webform code locally on my machine this works, because my machine is logged in to my user on the tfs server. But after deploying the code on a server I get a (401) unauthorized error message if I don't hardcode in my credentials like this
TfsConfigurationServer configurationServer = new TfsConfigurationServer(configurationServerUri, new NetworkCredential(user, pwd, domain));
(Locally the code below works)
TfsConfigurationServer configurationServer = new TfsConfigurationServer(configurationServerUri);
Is it possible to tell the webserver which user is logged into the machine accessing the webform, or is it any way I can prompt the user for username/password when he/she submits the webform?
thx for any help!
There are several things you need to do and approach this issue
First most likely you have anonymous authentication allowed for your website. Meaning users can access your site without any restrictions and wont need to provide any information. Webserver doesn't know who they are. This will need to be disabled as by your question you need their info. You web app will try to connect to tfs under the webservers identity - either the dedicated account running the application pool or computer account.
http://technet.microsoft.com/en-us/library/cc770966(v=ws.10).aspx
The most simplest method is to enable basic authentication for your website, this will request users to provide username and password, downside is this method transmits data in base64 plain text, as such you channel must be secure
http://technet.microsoft.com/en-us/library/cc772009(v=ws.10).aspx
Forms authentication will allow you to use custom form to collect login info from users, and validate it yourself but works much like basic authentication
http://technet.microsoft.com/en-us/library/cc753252(v=ws.10).aspx
If clients are users in your domain and application is used in intranet the best option is to use Windows authentication, it will try to automatically get users identity from domain, and will issue popup if that fails. Depending how your servers are setup getting this to work may be as easy as enabling it (tfs and your app on the same server) or require configuring your domain controllers for kerberous.
http://technet.microsoft.com/en-us/library/cc754628(v=ws.10).aspx
Once users are in have been authenticated you must make the webserver impersonate them when your code calls tfs. Complexity again depends on your setup.
http://technet.microsoft.com/en-us/library/cc730708(v=ws.10).aspx
Alternativly you can use tfs impersonation to get similar result, this can be also used if for example you dont have users in tfs for each user connecting but instead want to impersonate and ClientCompany, Project or Team account
http://blogs.msdn.com/b/paulking/archive/2010/11/04/using-the-new-tfs-2010-impersonation-apis.aspx

How to Elevate Role in ASP.net From anonymous to windows auth?

I have a few websites which allow both anonymous and window auth users at the same time. Basically if you hit the site with IE or Webkit based browsers on a windows system, the server instantly recognizes your active directory user and group.
In the past I've provided a link to a windows auth only page which allows the current user to login, or bounce back to where they started.
I find the management of this kind of frustrating as I need to make certain that IIS has the correct security settings for that single page after every deployment.
Is there a better way for me to allow a user to elevate from anon to authenticated?
There is no other way to do that elevation automatically. The server can't know that the current user is a Windows user and elevate them, or automatically redirect them to the Windows auth only page. On the other hand, if every user will get through the Windows auth only page, all of them which are not inside the domain will see the challenge/response dialog box (user + password).
As for the management part of making sure that this special page has the correct security settings, you can (and should) automate the check somehow. For example, by querying the IIS metabase for that setting when the application starts (in Global.asax) and if the setting is not there, log it as an email message or so.
Personally I prefer a different attitude - a special "integration/deployment" page which contains a series of tests against my application so I can make sure everything's set up correctly on the server, i.e. NTFS write permissions to certain folders, availability of the SMTP server set in web.config to send emails through, etc.
Note: You're using Windows authentication along with anonymous access. Just keep in mind that if you consider implementing Forms Authentication in the future, a misarchitecture (I don't know if by design or due to a flaw) of IIS 7 does not allow you to set the app to be Forms Authentication and set one specific page to be Windows Authentication. The override just doesn't work and it's very frustrating.
Good luck!
OK, I figured out a fairly nice way to do this...however it's not as elegant as I had hoped since it doesn't work across applications.
Basically, if you create a single page within your Anon + Integrated Auth IIS6 website or virtual directory, let's call it auth.aspx, then you can use this page to prompt authentication.
Go into IIS settings and specify that auth.aspx is Integrated Auth ONLY (no anon). Then create a hidden iframe somewhere on your page. I then created a simple JavaScript action to update the src attribute of the iframe to the auth.aspx page. This forces the browser to try and authenticate using NTLM. Once you enter valid credentials you've successfully elevated your current user beyond the generic anonymous user.
One final touch was to then include a Response.Redirect into the auth.aspx which reloads the current page. Assuming your ASP.net session tokens are set correctly, the page will reload and the user will be authenticated.

how to open a sharepoint page by providing the user credentials silently

I want to open a native SharePoint 2010 page from my application (for example the Edit Properties page of a document) without the need to enter username/password, but instead to authenticate silently (prior or during the page request). is that possible?
In other words, i have a windows forms application, i enter a sharepoint document path and i click on a button, this will open up a windows form with a browser control that will navigate to the native "editform.aspx" sharepoint 2010 page for this document.Is there a way to authenticate the user without the need for him to enter his credentials?
Thanks,
There is no way to pass credentials on the first visit to the SharePoint site. But if you are using an authentication option that allows saving (especially NTML) and the user's browser settings allow for saved passwords, then subsequent logins will be automatic. This would be same experience if they were to open a browser and navigate directly to the EditForm.aspx URL.
In IE you can set the "Automatic Login" settings in the Advanced Options. It treats URLs differently based on the zone, so it would be simpler if your page is in the user's "Intranet Zone".
If you set it up correctly, the first time they user your SharePoint site they will be prompted but every time after that they will be automatically logged in.
YOu could try setting the PreAuthenticate property of the WebRequest (which i assume your using). Although I have to admit to have seen similar questions with mixed results.
The logon challenge screen you get is inherent to NTLM:
from the NTLM wiki page:
"First, the client establishes a network path to the server and sends a NEGOTIATE_MESSAGE advertising its capabilities.[11] Next, the server responds with CHALLENGE_MESSAGE which is used to establish the identity of the client.[12] Finally, the client responds to the challenge with a AUTHENTICATE_MESSAGE".
And more about PreAuthenticate (MSDN):
"With the exception of the first request, the PreAuthenticate property indicates whether to send authentication information with subsequent requests without waiting to be challenged by the server. When PreAuthenticate is false, the WebRequest waits for an authentication challenge before sending authentication information."
By doing what Peter suggested (adding the site to your IE's Intranet Zone means your credentials will be cached and webrequest uses these cached requests and honors the settings in IE.

Prompt for login details when using Integrated Windows Authentication

For an ASP.NET application, how can I prompt the user for their username / password when Integrated Windows Authentication is used? I would like to use C# in the code behind of the pages to do this.
I want some pages (e.g. http://intranet/admin/) to prompt for a password, while others automatically go though (via IWA/NTLM). I would then like it to remember that the user has logged in as they visit other pages in the folder / site and offer a logout link for when they are finished.
Edit:
What I want to do is send a 401 status and WWW-Authentication headers to the user, so they then log in using their Windows Credentials.
Basically, how Firefox / IE do it if the site isn't trusted.
Edit 2:
SharePoint does this kind of thing, where you automatically log in, but can log out and log in as someone else without needing to log out of Windows.
Edit 3:
An example (other than SharePoint): You are logged in as a standard (limited access) Windows / Active Directory user to a trusted site, which passes on your credentials. You then want to log into an admin part of the site with different credentials (but still Windows, not WebForms). The only other way of doing it is if you log off Windows, then log in again. Not practical if you have files open (that you may wish to access) or the administrator can't log in locally (Interactive Login Privilege disabled). Impersonation may be set, as the page allows access to applications the regular user account doesn't (e.g. databases, files, Active Directory admin).
Basically making a page within the site behave as though it is not part of the Trusted Sites zone.
Sounds like you need to use Impersonation. This allows you to "run as" another Windows user. See here: ASP.NET Impersonation
Here are a couple CodeProject examples:
Windows Impersonation using C#
User Impersonation in .NET
No seperate code for this.
When the user/client open the particular pate eg., http://intranet/admin/index.aspx
if you configure the particular folder with windows authentication, the browser will
automatically ask for the username and password of the particular user/client.
so this is the configuration that you have to do in the IIS to the particular folder
to which you would like to apply the integrated windows authentication.

Categories

Resources