.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Custom Authentication - Accessing windows user via WindowsIdentity

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :SharePoint


I have a rest-based wcf webservice which currently uses a custom form of basic authentication (that is I perform basic authentication but validate the user/password against a custom db). I need to introduce windows authentication. I am using a request interceptor to perform the authentication.

  public class GatewayHostFactory : WebServiceHost2Factory
    protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
      string serviceURI = ConfigurationManager.AppSettings[Constants.ServiceURI];
      Uri webServiceAddress = new Uri(serviceURI);
      GatewayHost webServiceHost = new GatewayHost(serviceType, webServiceAddress);

      AuthenticationInterceptor Auth = new AuthenticationInterceptor("GatewayService");
      return webServiceHost;

and then as a authentication message comes in firstly trying to authenticate a windows

View Complete Post

More Related Resource Links

Forms based users being prompted for windows authentication login for My Sites photos in user lists

Here's an issue I didn't see coming for our forms based authentication users. 

We have a web application extended to an external url to handle forms based authentication for users outside of our domain. Our setup looks like this...

Internal Users/Windows Authentication - moss.domain.com
External Users/Forms Based - mossext.domain.com
My Site for Internal Users - mysites.domain.com

When our forms based users are accessing user lists, or discussion pages that display user pictures, they are getting a windows authentication login for our internal users (mysites.domain.com) who have populated their my site with personal photo.

How do we fix this? 

=User!UserID from windows authentication using table from another database



i'm using sql server 2005, sql server business intelligence development studio for my reports and deploy them in my wss3.0 site.

what i'm trying to do is i'm trying to restrict wich users can see specific data within a report.

now, the thing is. the report gets the data out of my DB1 database and my windows authenticated user are in the WSS_content database.

when i deploy my report in my wss3 site. it gets the user that is loged in. but of course it does not display any data because the tables are not in the same database.

does someone knows how to do this?

Automatic expiration of forms authentication when user closes the browser windows without signing ou

Dear all, can u tell me how to automatically sign out a user if he/she closes the browser window without signing out. I'm using Forms Authentication.   Thanks 

LDAP - directory entry issue with out user and password using impersonate and windows authentication

Hi All I am using the below code to fetch the user information from LDAP             DirectoryEntry entry = new DirectoryEntry("LDAP://DEV");             DirectorySearcher searcher =  new DirectorySearcher(entry);             SearchResult result;             searcher.Filter = "samaccountname=testuser";             result = searcher.FindOne(); here i am using windows authentication always and along with that when i enable the impersonate = true ,  the code fails at "result = searcher.FindOne();" with message "object reference not set to instance of an object "  also with the same code if i give the username and password along with the impersonate tag >> it works  or if i am using the user and password along with the DirectoryEntry  object then also it will work  but it fails with same user that i gave in impersonate tag / directory entry object with windows authentication enabled  and the  user logged to the application and no username and password tag in directory entry / impersonate tag  Interesting thing is that  in our development server ,  i am able to execute the same code with out user name p

need help with sharepoint (wss 3.0) with Windows authentication and Custom Role provider

I'm trying to setup sharepoint(wss 3.0) to use my custom role provider with Windows authentication. I've modified the web.config to enable role manager and I am able to select my custom roles when assigning permissions but it doesn't seem like sharepoint is check the permission again my custom roles. If I enable Forms authentication and use my custom membership provider it all works as expected but I do not want to use FBA because of the issues with Client Integration. Essentially I want all the features that comes with the default windows authentications but just have permission be control from my custom role provider. Can anyone offer any solution or suggestions?

Create single custom login page for Windows Authentication and Form Based Authentication.


I want to create a custom login page for both Windows Authentication and Form Based Authentication.

I mean to I have to create only single login page for both authentication.

How can I create this kind of page?

G. Goyal

WCF service IIS7 Server 2008 custom User Name Authentication performance



I have WCF service. Nothing special. Everithing from "best-practice".

  • WCF Service hosted on Server2008(64)\IIS7
  • Application pool - integrated\.NET 4.0
  • binding: basicHttpBinding; security:TransportWithMessageCredential
  • transport clientCredentialType="None"
  • message clientCredentialType="UserName
  • custom class inherited from UserNamePasswordValidator provide simple validation.

Everything works as designed. But I have a performance issue.

I traced and logged the server and WCF class and figured out that there is no new "http request" in process until previous one passed "Verification". It looks like concurrent calls do not have any sense because UserName Password Validator may serve them one by one only.

It can't be a true. I hope I just missed some settings.

I will appreciate any help.


Building a custom Login Page which does not use forms or windows authentication



I would like to build a custom login page which doesnt uses the windows or forms authentication but I am troubled as to how I should do that. I tried to follow the default AccountController.vb file but it doesnt help me much as it doesnt show where its connecting with the database.

What is need is:

Database Table User

columns are userid, email, password

to write a login page that will use my sql server to login rather than using the forms or windows authentication

Web Matrix + Windows Authentication


I'm curious if its possible to get windows auth working with asp.net webpages/webmatrix.

I've got it published to IIS with windows auth turned on and anonymous/forms/basic turned off.

I'm guessing the WebSecurity Helper probably won't work here but can you access User.Identity.Name etc?

Sorry for the newbie questions, I've only just started working with asp.net ^^,

Windows Authentication for IIS in Windows 7 Home Premium Edition - for ASP Websites.


How to create a virtual directory and get benefit of the IIS. Is there a workaround to accomplish this without the Windows Authentication for Windows 7 Home Premium Edition?

Thanks in advance, 

How to authenticate local user usin ldap or non domain authentication



I created one application, and I need to authenticate local user. This user is the user who is login to his/her Personal Computer.. Main thing his that he/she does not in any DOMAIN... I want NON-DOMAIN authentication.. any how.... please help...

help needed: Ldap User authentication using userDN and password



Is it possible to authenticate a user using userDN and password? If so, then tell me the syntax.So far i have tried to authenticate using username and password from my c# code using directoryentry which takes the parameters like domainname,username and password. But i need to authenticate using Userdn and password.

Using windows authentication to access SQL when using ASP.NET 4.0 via COM+


I am using SQL Server 2008 under windows authentication, front end is ASP.NET which uses COM+ to access database.

COM+ components are configured to run as domain user.

When looking through the logs (SQL Profiler), I can see the login name as the configured identity instead of windows indentity.

I have got Website running under "Intergrated Windows Authentication" and database is running locally on webserver.

Web configure contains entry for <identity impersonate="true"/>.

My connection string is

connectionString="data source=db01\test01;initial catalog=test; integrated security=SSPI;persist security info=False; Trusted_Connection=Yes"

Any ideas?




No ASPNET User in Windows Server 2008?


I have been looking everywhere online regarding this, but have not found a clear answer.


I have an ASP.Net app running on Windows Server 2008, it's basically a reporting app using Crystal Reports. I have encountered a roadblock in regards to rendering some pages. When I run the app in Visual Studio(on the same 2008 machine) everything works perfectly. Yet when I publish it and run it live the reports will not display correctly, I get a message saying Failed to render page.


I looked this error up in the Crystal Reports website and the fixes they have there refer to giving the windows "aspnet" user full access rights to certain folders on the machine. I would be happy to do this, however there is no aspnet user in Windows Server 2008.


I installed the server and set its role to be Web Server. I also checked all the options regarding ASP.Net and IIS 6 compatibility. Yet there is no ASPNET username anywhere.


Did I set the server up wrong? or do I have to do something within ASP.Net to  create this user and then give it rights? 

Cmdlets: Extend Windows PowerShell With Custom Commands


Jim Truher presents an introduction to writing and registering your own custom cmdlets to be used in Windows PowerShell.

Jim Truher

MSDN Magazine December 2007

Least Privilege: Teach Your Apps To Play Nicely With Windows Vista User Account Control


User Account Control in Windows Vista keeps the OS safe from intentional and accidental configuration changes.

Chris Corio

MSDN Magazine January 2007

Desktop Security: Create Custom Login Experiences With Credential Providers For Windows Vista


Why is a change to the Windows logon plug-in interface so exciting? Because with credential providers you can customize the logon experience for your users.

Dan Griffin

MSDN Magazine January 2007

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend