本文整理汇总了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();
}
示例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;
}