0
클라이언트가 폼 인증을 사용하여 Asp.net 웹 응용 프로그램 기반에 요청을 보냈습니다. 어떻게 활성 디렉토리의 로그인 사용자 이름을 얻을 수 있습니까?Asp.net 폼 인증에서 사용자 도메인을 검색합니다.
클라이언트와 웹 응용 프로그램이 모두 동일한 도메인에 있습니다. 내 인트라넷 응용 프로그램에서
클라이언트가 폼 인증을 사용하여 Asp.net 웹 응용 프로그램 기반에 요청을 보냈습니다. 어떻게 활성 디렉토리의 로그인 사용자 이름을 얻을 수 있습니까?Asp.net 폼 인증에서 사용자 도메인을 검색합니다.
클라이언트와 웹 응용 프로그램이 모두 동일한 도메인에 있습니다. 내 인트라넷 응용 프로그램에서
내가 이런 식으로 뭔가를 사용 :
/// <summary>
/// Authenticate the user, with windows auth(and domain)
/// If that fails then authenticate with forms
/// If that fails...well, go to hell
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e) {
//First try the windows login (domain+username/password)
Logging.IntranetLogger.LogIntranetActionInfo(Logging.IntranetLogConst.Logging, Logging.IntranetLogConst.UserTryToLoggIn, loginControl.UserName);
string domainName = GetDomainName(loginControl.UserName); // Extract domain name
//form provide DomainUsername e.g Domainname\Username
string userName = GetUsername(loginControl.UserName); // Extract user name
//from provided DomainUsername e.g Domainname\Username
IntPtr token = IntPtr.Zero;
//userName, domainName and Password parameters are very obvious.
//dwLogonType (3rd parameter):
// I used LOGON32_LOGON_INTERACTIVE, This logon type is
// intended for users who will be interactively using the computer,
// such as a user being logged on by a terminal server, remote shell,
// or similar process.
// This logon type has the additional expense of caching
// logon information for disconnected operations.
// For more details about this parameter please see
// http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx
//dwLogonProvider (4th parameter) :
// I used LOGON32_PROVIDER_DEFAUL, This provider use the standard
// logon provider for the system.
// The default security provider is negotiate, unless you pass
// NULL for the domain name and the user name is not in UPN format.
// In this case, the default provider is NTLM. For more details
// about this parameter please see
// http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx
//phToken (5th parameter):
// A pointer to a handle variable that receives a handle to a
// token that represents the specified user. We can use this handler
// for impersonation purpose.
//authenticate with the inputed
bool windowsLoginResult = LogonUser(userName, domainName, loginControl.Password, 2, 0, ref token);}
[DllImport("ADVAPI32.dll", EntryPoint = "LogonUserW", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
코드가없는 내,이 곳 CodeProject의에에서 가져됩니다
, 나는 내가 기억하지 못하는 죄송 정확히 어디에서와 저자
이 답변은 내가 찾고있는 답변이 아닙니다. – mehrdad