當前位置: 首頁>>代碼示例>>C#>>正文


C# UserPrincipal.OfficeLocation方法代碼示例

本文整理匯總了C#中System.DirectoryServices.AccountManagement.UserPrincipal.OfficeLocation方法的典型用法代碼示例。如果您正苦於以下問題:C# UserPrincipal.OfficeLocation方法的具體用法?C# UserPrincipal.OfficeLocation怎麽用?C# UserPrincipal.OfficeLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.DirectoryServices.AccountManagement.UserPrincipal的用法示例。


在下文中一共展示了UserPrincipal.OfficeLocation方法的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.OfficeLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。