简体   繁体   English

Office 365单一登录

[英]Office 365 Single Sign On

I've been attempting to do SSO for Office365 and have federated my AD with Office365. 我一直在尝试为Office365做SSO,并将我的广告与Office365联合在一起。 When I reach portal.microsoftonline.com and enter a username from my domain eg: user@mydomain.com, the page gets redirected to my ADFS for authentication, there after the user keys in his/her credentials. 当我到达portal.microsoftonline.com并从我的域中输入用户名,例如:user@mydomain.com时,该页面将重定向到我的ADFS进行身份验证,然后在用户键入他/她的凭据之后。

Is there a way to do a active authentication for Office365, if I used the term correctly, where a user logs into my site which already actively authenticates a user using a HttpBinding to my ADFS then also gets authenticated for Office365? 如果我正确使用了术语,是否有一种方法可以对Office365进行主动身份验证,即用户登录到我的站点,该站点已经使用HttpBinding到我的ADFS对用户进行了主动身份验证,然后又对Office365进行了身份验证?

The high level flow is as follow: 高层流程如下:

  1. User signs into my website which is authenticated against the ADFS via active authentication 用户登录到我的网站,该网站通过主动身份验证针对ADFS进行了身份验证
  2. User proceeds to Office365 and should not need to log in again. 用户继续使用Office365,无需再次登录。

No. For SSO to work, a cookie must be set in the donain where ADFS is running. 不能。为了使SSO正常工作,必须在运行ADFS的donain中设置cookie。 And the only way to achieve this is authenticating with the browser. 实现此目的的唯一方法是使用浏览器进行身份验证。 When you do active auth the browser is not involved (it is a server to server call) 执行主动身份验证时,不涉及浏览器(它是服务器到服务器的调用)

Programmatically, using IE and Powershell, you could do it with a COM object like below. 通过编程,使用IE和Powershell,可以使用如下COM对象来实现。 The full code for an automatic login (+drivemap, which the code is from) is here: http://www.lieben.nu/numb3rs/?page_id=129 自动登录的完整代码(该代码来自+ drivemap)在此处: http : //www.lieben.nu/numb3rs/? page_id=129

#start invisible IE instance
try{
    $ie = new-object -com InternetExplorer.Application
    $ie.visible = $debugmode
}catch{
    ac $logfile "failed to start Internet Explorer COM Object, check user permissions`n"
    ac $logfile $error[0]
    Exit
}
#navigate to OneDrive and log out
$ie.navigate("http://login.microsoftonline.com/logout.srf")
do {sleep 1} until (-not ($ie.Busy)) 
$ie.quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie) > $null
Remove-Variable ie

#start invisible IE instance
$ie = new-object -com InternetExplorer.Application
$ie.visible = $debugmode

#login process
do{
    $ie.navigate("https://"+$O365CustomerName+"-my.sharepoint.com/personal/"+$userURL")
    do {sleep 1} until (-not ($ie.Busy))

    #click to open up the login menu
    do {sleep 1} until (-not ($ie.Busy))
    try { 
        $ie.document.GetElementById("_link").click()
        do {sleep 1} until (-not ($ie.Busy)) 
    } catch {$null}

    #attempt automated login using ADFS / non ADFS methods
    if($useADFS){
        ac $logfile "useADFS set to true`n"
        ac $logfile "attempting ADFS single sign-on`n"
        #trigger redirect
        try{
            $ie.document.GetElementById("cred_keep_me_signed_in_checkbox").click()
            $ie.document.GetElementById("cred_userid_inputtext").value = $userUPN
            do {sleep 1} until (-not ($ie.Busy)) 
            $ie.document.GetElementById("cred_sign_in_button").click()
            do {sleep 1} until (-not ($ie.Busy))
        }catch{
            ac $logfile "Failed to find the correct controls at $($ie.locationURL) to log in by script, check your browser and proxy settings or check for an update of this script`n"
        }
        #ADFS redirect can take a while
        do {sleep 1} until (-not ($ie.Busy))
        Sleep -s1
        do {sleep 1} until (-not ($ie.Busy))
        sleep -s $ADFSWaitTime
        do {sleep 1} until (-not ($ie.Busy))
    }else{
        try{
            $ie.document.GetElementById("cred_userid_inputtext").value = $userUPN
            $ie.document.GetElementById("cred_password_inputtext").value = $password
            $ie.document.GetElementById("cred_keep_me_signed_in_checkbox").click()
            do {sleep 1} until (-not ($ie.Busy)) 
            $ie.document.GetElementById("cred_sign_in_button").click()
            do {sleep 1} until (-not ($ie.Busy))
        }catch{
            ac $logfile "Failed to find the correct controls at $($ie.locationURL) to log in by script, check your browser and proxy settings or check for an update of this script`n"
        }
        sleep -s 1
        do {sleep 1} until (-not ($ie.Busy))
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM