Home > Net >  Asp.net webform written how to realize the automatic login domain account
Asp.net webform written how to realize the automatic login domain account

Time:09-26

Everybody is good, the couple small white has a problem, said the background:
Developed a webform test project, in the company's Intranet environment, deployed in one domain environment on the will of the machine, as a server machine and to access the web users in the same domain, how to realize the system domain account landing directly?

What did I do:
1 - under local VS test, has been get through code and domain account, event code I was literally create web pages written in backend cs file,
2 - to find some materials, understand the need to configure the web. Config file, such as Windows authentication, cancel the anonymous authentication, etc.,
3 - access to the site, no longer turn to initial page, but into the Account/Login. Aspx page, get an error is as follows:
The request filtering module is configured to refuse to contain the query string of long request
http://localhost:5285/Account/Login? ReturnUrl=% 2 faccount... (an error page in the login page)...

My question: what should I write for domain account code in the project? My understanding is that set to cancel anonymously, validated website will automatically go to the login page, I the above error is that there is no verification results of success, that where is my verification code? I only get domain account name without authentication codes, just to present who visit this site record
At the same time, if subsequent validation successful how to make the master page a foot show the user name?

Self-study, the foundation is not solid, glad,

CodePudding user response:

Put your written test time for domain account code: (I'm testing has established the webform page, and then the background)
 WindowsPrincipal wp=new WindowsPrincipal (WindowsIdentity. GetCurrent ()); 
String [] logon=wp. Identity. The Name, the Split (' \ \ ');
String UserDomain=logon [0];//domain
Lb_User. Text=logon [1]. The ToString (). ToLower ();//land user


This is to be able to obtain the domain account, but I don't know how to apply to the entire site, wrote where I don't know.

CodePudding user response:

I feel this part of the need to account in the database is initialized, after the success of the login using this account and the account match in the database, and then according to the database permission to do the corresponding operation, such as
  • Related