![](/img/trans.png)
[英]How can i read data from .accdb access using php?(windows & linux)
[英]How can I access windows services or data from windows machine from my website using PHP?
这是关于 PHP 中单点登录的实现。
我有一个网站说 abc.com,我想检查一下,用户是否登录了他/她的 outlook 邮件? 表示我想通过使用网站在 web 上实现单点登录,从用户的本地计算机获取用户的 email 地址。
或者您可以说我想检查用户配置文件(在 windows 机器上使用的电子邮件 ID 以访问 windows 应用程序)
如果用户使用 window 系统并且他登录到 outlook 这意味着任何特定的网站、链接或 api 将返回一些标志等,可能还有另一种解决方法。
活动目录用于管理网络内的用户,现在微软使用基于云的解决方案,如 Azure 和 SAML 2.0 等。
但是,您的问题是关于活动目录的使用,那么首先您必须了解活动目录域设置,AD 用于获取系统用户信息以验证为特定用户创建的访问级别。 In.Net 获取具有域的 AD 用户的简单代码是:
public static void Main() {
DisplayUser(WindowsIdentity.GetCurrent());
Console.ReadKey();
}
public static void DisplayUser(IIdentity id) {
WindowsIdentity winId = id as WindowsIdentity;
if (id == null) {
Console.WriteLine("Identity is not a windows identity");
return;
}
string userInQuestion = winId.Name.Split('\\')[1];
string myDomain = winId.Name.Split('\\')[0]; // this is the domain that the user is in
// the account that this program runs in should be authenticated in there
DirectoryEntry entry = new DirectoryEntry("LDAP://" + myDomain);
DirectorySearcher adSearcher = new DirectorySearcher(entry);
adSearcher.SearchScope = SearchScope.Subtree;
adSearcher.Filter = "(&(objectClass=user)(samaccountname=" + userInQuestion + "))";
SearchResult userObject = adSearcher.FindOne();
if (userObject != null) {
string[] props = new string[] { "title", "mail" };
foreach (string prop in props) {
Console.WriteLine("{0} : {1}", prop, userObject.Properties[prop][0]);
}
}
}
实际上,获取系统用户名和获取用于 Microsoft 登录的 email 地址是不同的两个过程。
要获取系统或操作系统用户,您可以使用下面的 javascript 代码,称为 activeXObject,为此您必须在 IE 中从安全选项卡中启用 activeXObject(我刚刚为 Internet Explorer 测试过):
$(document).ready(function () {
try {
var activex = new ActiveXObject('WScript.Network');
alert(activex.userName);
} catch (ex) {
alert("unable to get user info");
}
}
所以最后回答你的问题,你不能在不使用 AD 或 SAML 等的情况下直接获得 email id。
您可以使用Microsoft Graph SDK for PHP来制作Outlook ZDB97423871048DE63FZA7ACE1 调用。 为了做到这一点,您可以按照本教程进行操作。
这将要求用户每次登录以授予访问权限。 要修复它,已经有答案了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.