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


C# UserPrincipal.Manager方法代码示例

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


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

示例1: AdUser

 public AdUser(UserPrincipal userPrincipal)
 {
     AutoMapper.Mapper.Map(userPrincipal, this);
     OfficeLocation = userPrincipal.OfficeLocation();
     Manager = userPrincipal.Manager();
 }
开发者ID:ucdavis,项目名称:CAM,代码行数:6,代码来源:IActiveDirectoryService.cs

示例2: CreateAdUser

        /*
         * Edit funcations
         */
        private string CreateAdUser(AdUser adUser, string container, List<string> securityGroups)
        {
            string loginId, manager = string.Empty;

            // find the supervisor
            if (!string.IsNullOrEmpty(adUser.ManagerKerb))
            {
                var supervisor = GetUserByEmployeeId(adUser.ManagerKerb);
                if (supervisor != null) manager = supervisor.DistinguishedName;
            }

            using (var upc = new PrincipalContext(ContextType.Domain, Site.ActiveDirectoryServer, container, UserName, Password))
            {
                loginId = CheckForExistingUser(adUser.FirstName, adUser.LastName, upc);

                if (loginId == null)
                {
                    throw new DuplicateNameException("Unable to determine a valid userid for the requested user.");
                }

                var user = new UserPrincipal(upc);
                AutoMapper.Mapper.Map(adUser, user);

                user.SamAccountName = loginId;
                user.UserPrincipalName = string.Format("{0}@caesdo.caes.ucdavis.edu", loginId);
                user.Enabled = true;
                if (adUser.LastName.ToLower() != loginId)
                {
                    user.Name = string.Format("{0}, {1} ({2})", adUser.LastName, adUser.FirstName, loginId);
                }

                user.SetPassword(GeneratePassword(16));

                //if (adUser.NeedsEmail)
                //{
                //    user.EmailAddress = string.Format("{0}@caes.ucdavis.edu", loginId);
                //}

                user.Save();

                foreach (var groupId in securityGroups)
                {
                    AddToGroup(user, groupId);
                }
            }

            // assign attributes that must be done after saving
            using (var ad = new PrincipalContext(ContextType.Domain, Site.ActiveDirectoryServer, container, UserName, Password))
            {
                var user = UserPrincipal.FindByIdentity(ad, loginId);

                // set the extended properties that cannot be done before first save
                user.OfficeLocation(adUser.OfficeLocation);
                user.Manager(manager);

                user.Save();
            }

            return loginId;
        }
开发者ID:ucdavis,项目名称:CAM,代码行数:63,代码来源:IActiveDirectoryService.cs


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