当前位置: 首页>>代码示例>>C#>>正文


C# Web.GetAuthenticationRealm方法代码示例

本文整理汇总了C#中Web.GetAuthenticationRealm方法的典型用法代码示例。如果您正苦于以下问题:C# Web.GetAuthenticationRealm方法的具体用法?C# Web.GetAuthenticationRealm怎么用?C# Web.GetAuthenticationRealm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Web的用法示例。


在下文中一共展示了Web.GetAuthenticationRealm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddReaderAccessImplementation

        private static void AddReaderAccessImplementation(Web web, BuiltInIdentity user)
        {
            switch (user)
            {
                case BuiltInIdentity.Everyone:
                    {
                        string userIdentity = "c:0(.s|true";
                        var spReader = web.EnsureUser(userIdentity);
                        web.Context.Load(spReader);
                        web.Context.ExecuteQuery();

                        web.AssociatedVisitorGroup.Users.AddUser(spReader);
                        web.AssociatedVisitorGroup.Update();
                        web.Context.ExecuteQuery();
                        break;
                    }
                case BuiltInIdentity.EveryoneButExternalUsers:
                    {
                        string userIdentity = string.Format("c:0-.f|rolemanager|spo-grid-all-users/{0}", web.GetAuthenticationRealm());
                        var spReader = web.EnsureUser(userIdentity);
                        web.Context.Load(spReader);
                        web.Context.ExecuteQuery();

                        web.AssociatedVisitorGroup.Users.AddUser(spReader);
                        web.AssociatedVisitorGroup.Update();
                        web.Context.ExecuteQuery();
                        break;
                    }
            }
        }
开发者ID:ADefWebserver,项目名称:PnP,代码行数:30,代码来源:SecurityExtensions.cs

示例2: AddReaderAccessImplementation

        private static User AddReaderAccessImplementation(Web web, BuiltInIdentity user)
        {
            switch (user)
            {
                case BuiltInIdentity.Everyone:
                    {
                        const string userIdentity = "c:0(.s|true";
                        User spReader = web.EnsureUser(userIdentity);
                        web.Context.Load(spReader);
                        web.Context.ExecuteQueryRetry();

                        web.AssociatedVisitorGroup.Users.AddUser(spReader);
                        web.AssociatedVisitorGroup.Update();
                        web.Context.ExecuteQueryRetry();
                        return spReader;
                    }
                case BuiltInIdentity.EveryoneButExternalUsers:
                    {
                        User spReader = null;
                        try
                        {
                            // New tenant
                            string userIdentity = string.Format("c:0-.f|rolemanager|spo-grid-all-users/{0}", web.GetAuthenticationRealm());
                            spReader = web.EnsureUser(userIdentity);
                            web.Context.Load(spReader);
                            web.Context.ExecuteQueryRetry();
                        }
                        catch (ServerException)
                        {
                            // old tenant?
                            string userIdentity = string.Empty;

                            web.Context.Load(web, w => w.Language);
                            web.Context.ExecuteQueryRetry();

                            switch (web.Language)
                            {
                                case 1025: // Arabic
                                    userIdentity = "الجميع باستثناء المستخدمين الخارجيين";
                                    break;
                                case 1069: // Basque
                                    userIdentity = "Guztiak kanpoko erabiltzaileak izan ezik";
                                    break;
                                case 1026: // Bulgarian
                                    userIdentity = "Всички освен външни потребители";
                                    break;
                                case 1027: // Catalan
                                    userIdentity = "Tothom excepte els usuaris externs";
                                    break;
                                case 2052: // Chinese (Simplified)
                                    userIdentity = "除外部用户外的任何人";
                                    break;
                                case 1028: // Chinese (Traditional)
                                    userIdentity = "外部使用者以外的所有人";
                                    break;
                                case 1050: // Croatian
                                    userIdentity = "Svi osim vanjskih korisnika";
                                    break;
                                case 1029: // Czech
                                    userIdentity = "Všichni kromě externích uživatelů";
                                    break;
                                case 1030: // Danish
                                    userIdentity = "Alle undtagen eksterne brugere";
                                    break;
                                case 1043: // Dutch
                                    userIdentity = "Iedereen behalve externe gebruikers";
                                    break;
                                case 1033: // English
                                    userIdentity = "Everyone except external users";
                                    break;
                                case 1061: // Estonian
                                    userIdentity = "Kõik peale väliskasutajate";
                                    break;
                                case 1035: // Finnish
                                    userIdentity = "Kaikki paitsi ulkoiset käyttäjät";
                                    break;
                                case 1036: // French
                                    userIdentity = "Tout le monde sauf les utilisateurs externes";
                                    break;
                                case 1110: // Galician
                                    userIdentity = "Todo o mundo excepto os usuarios externos";
                                    break;
                                case 1031: // German
                                    userIdentity = "Jeder, außer externen Benutzern";
                                    break;
                                case 1032: // Greek
                                    userIdentity = "Όλοι εκτός από εξωτερικούς χρήστες";
                                    break;
                                case 1037: // Hebrew
                                    userIdentity = "כולם פרט למשתמשים חיצוניים";
                                    break;
                                case 1081: // Hindi
                                    userIdentity = "बाह्य उपयोगकर्ताओं को छोड़कर सभी";
                                    break;
                                case 1038: // Hungarian
                                    userIdentity = "Mindenki, kivéve külső felhasználók";
                                    break;
                                case 1057: // Indonesian
                                    userIdentity = "Semua orang kecuali pengguna eksternal";
                                    break;
//.........这里部分代码省略.........
开发者ID:neoassyrian,项目名称:PnP-Sites-Core,代码行数:101,代码来源:SecurityExtensions.cs


注:本文中的Web.GetAuthenticationRealm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。