如何使用PHP从我的网站从Windows计算机访问Windows服务或数据?

这是有关在PHP中实现单点登录的信息。

  

我有一个网站说abc.com,我要检查,用户是否已登录   他/她的前景邮件?表示我想获取用户的电子邮件地址   从他的本地计算机(通过使用网站实施单一登录)上   网络。

     

或者您可以说我想检查用户个人资料(在Windows机器上用来获取Windows应用程序的电子邮件ID)

可能还有另一种解决方法,例如,如果用户使用的是窗口系统,并且他登录到Outlook中,则意味着任何特定的网站,链接或api都将返回一些标志等。

imagin_0707 回答:如何使用PHP从我的网站从Windows计算机访问Windows服务或数据?

  

Active Directory用于管理网络中的用户,如今,Microsoft使用基于云的解决方案(如带有SAML 2.0等的Azure)已经成为当今的

     

但是,如果您的问题是关于活动目录的使用,那么首先您必须了解活动目录域设置,AD用于获取系统用户信息以验证为特定用户创建的访问级别。在.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登录的电子邮件地址都是两个不同的过程。

要获取系统或OS用户,您可以使用下面的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等,您将无法直接获得电子邮件ID。

,

您可以仅使用Microsoft Graph SDK for PHP来制作Outlook API Calls。为此,您可以遵循this tutorial

这将要求用户每次登录才能授予访问权限。要解决此问题,请there's already an answer for it

本文链接:https://www.f2er.com/3161707.html

大家都在问