2011-01-30 1 views
0

SP2010 사이트에 대한 사용자 지정 로그인 페이지를 만드는 것이 시급합니다. 이제는 클레임 ​​기반 인증 및 FBA로이 작업을 수행 할 수 있음을 알았지 만 수 일간의 작업을 마친 후에는 완료 할 수 없어 다른 접근 방식으로 바뀌 었습니다.Sharepoint 2010 다른 웹 사이트 로그인

어쩌면 나는 사용자를 환영하고 인증 할 .NET으로 전면 웹 사이트를 만들 수 있습니다. 그런 다음 내 SP2010 사이트에 대해 "세션 상태"를 설정 한 다음 사용자를 sp2010 사이트로 리디렉션 할 수 있습니다. 이것이 어떤 방식 으로든 가능할지 모르지만 배우고 싶습니다.

SP2010 용 사용자 정의 로그인 페이지를 만드는 다른 제안이 있습니다.

미리 감사드립니다.

답변

0

안녕하세요 저는 SharePoint 2007의 모바일 장치에서 사용자를 인증 할 수 있어야하며 사용자 지정 로그인을 만들고 싶었습니다.

이 작업을 수행하는 것이 훨씬 쉽고/더 좋은 방법 일 수 있지만 SharePoint 사이트에서이 작업을 먼저 수행 한 다음 활성 디렉터리를 확인해야했습니다.

(사용자 개체는 WCF를 통해 암호화 된 데이터의 일종했지만, 기본적으로 사용자 이름과 암호 준) 장기적으로

/// <summary> 
    /// Authenticate whether the user is a user of SharePoint by their username and password 
    /// </summary> 
    /// <param name="LoggedIn">The user that is to be authenticated</param> 
    /// <param name="SharePointSiteAddress">The address of the SharePoint site</param> 
    /// <returns>The name of the user if they are authenticated or null if not</returns> 
    public string AuthenticateSharePointUser_UsePassword(User LoggedIn, string SharePointSiteAddress) 
    { 
     string nameResult = null; 

     try 
     { 

      Authentication authentication = new Authentication(); 

      //Check against active directory first 
      bool isAuthenticated = authentication.AuthenticateUserActiveDirectory(LoggedIn.GetUserName(), LoggedIn.GetPassword()); 

      if (isAuthenticated) 
      { 
       nameResult = authentication.AuthenticateSharePointUserName(LoggedIn.GetUserName(), SharePointSiteAddress); 
      } 
     } 
     catch (Exception ex) 
     { 
      throw new Exception("Authentication Error", ex); 
     } 

     return nameResult; 
    } 

    /// <summary> 
    /// Authenticate that a user exists on SharePoint 
    /// </summary> 
    /// <param name="UserName">The username of the user to check</param> 
    /// <param name="SiteAddress">The address of the site to check user on</param> 
    /// <returns>The name of the user or null if not</returns> 
    public string AuthenticateSharePointUserName(string UserName, string SiteAddress) 
    { 
     string user = null; 

     //Open up the site and get the list 
     using (SPSite site = new SPSite(SiteAddress)) 
     { 
      using (SPWeb web = site.OpenWeb()) 
      { 
       try 
       { 
        user = web.AllUsers[GetFullDomainUserName(UserName)].Name; 
       } 
       catch (Exception) 
       { 
        //Swallow exception from the user not existing 
        user = null; 
       } 
      } 
     } 
     return user; 
    } 

    /// <summary> 
    /// Authenticate the user against active directory 
    /// </summary> 
    /// <param name="UserName">The username that can include the domain name domain\username or just username</param> 
    /// <param name="Password">The password</param> 
    /// <returns>Whether the user has been authenticated</returns> 
    public bool AuthenticateUserActiveDirectory(string UserName, string Password) 
    { 
     //Split on the domain name e.g. domain\... 
     string[] splitUserName = GetFullDomainUserName(UserName).Split('\\'); 
     PrincipalContext context = null; 

     bool authenticated = false; 

     //Provide user domain if there is one to validate against or use current domain thread is running on 
     context = new PrincipalContext(ContextType.Domain, splitUserName[0]); 

     //Now validate against active directory 
     using (context) 
     { 
      authenticated = context.ValidateCredentials(splitUserName[1], Password); 
     } 

     return authenticated; 
    } 

    /// <summary> 
    /// Get a full domain name inclusive username from username given 
    /// if there is not already a domain name in it then attach current domain on this machine 
    /// </summary> 
    /// <param name="UserName">The username provided by user</param> 
    /// <returns>User name in style e.g. domain\----</returns> 
    public static string GetFullDomainUserName(string UserName) 
    { 
     //Split on the domain name e.g. net\356789 
     string[] splitUserName = UserName.Split('\\'); 

     //If the user gave a domain name then use that domain else use the current domain 
     if (splitUserName.Length <= 1) 
     { 
      splitUserName = new string[] { Environment.UserDomainName, UserName }; 
     } 

     return string.Join("\\", splitUserName); 
    } 
1

, 나는 당신이 당신의 문제를 해결할 수 있다고 질문을 더 나을 것이라고 생각을 CBA 및 FBA를 사용하는 경우 해결 방법에 사용자 정의 단일 사인을 함께 해킹 할 수 있습니다.