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


C# Principal.GetUnderlyingObject方法代码示例

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


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

示例1: GetDirectoryEntry

        public static DirectoryEntry GetDirectoryEntry(Principal principal)
        {
            if (principal == null)
            {
                throw new ArgumentNullException("principal", "Value cannot be null!");
            }

            return principal.GetUnderlyingObject() as DirectoryEntry;
        }
开发者ID:Eugene-Ishkov,项目名称:RestService,代码行数:9,代码来源:LdapPrincipalManager.cs

示例2: GetProperty

 private static string GetProperty(Principal principal, String property)
 {
     //using (WindowsImpersonationContextFacade impersonationContext
     //    = new WindowsImpersonationContextFacade(
     //        nc))
     //{
         var result = string.Empty;
         var directoryEntry = principal.GetUnderlyingObject() as DirectoryEntry;
         if (directoryEntry != null)
         {
             if (directoryEntry.Properties.Contains(property))
                 result = directoryEntry.Properties[property].Value.ToString();
             else
                 result = string.Empty;
         }
         return result;
     //}
 }
开发者ID:aleks19921015,项目名称:TenderProcessing,代码行数:18,代码来源:UserHelper.cs

示例3: ToDomainGroup

 private static DomainGroup ToDomainGroup(Principal principal)
 {
     try
     {
         var directoryEntry = principal.GetUnderlyingObject() as DirectoryEntry;
         return new DomainGroup
         {
             Name = principal.Name,
             Guid = principal.Guid.ToString(),
             DivisionId = directoryEntry.GetDivisionId(),
             Description = principal.Description
         };
     }
     catch (System.Exception)
     {
         return new DomainGroup();
     }
 }
开发者ID:pashaiva,项目名称:psub.Web,代码行数:18,代码来源:DomainUserService.cs

示例4: AccessCheck

        internal override bool AccessCheck(Principal p, PrincipalAccessMask targetPermission)
        {
            GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "AccessCheck " + targetPermission.ToString());

            switch (targetPermission)
            {
                case PrincipalAccessMask.ChangePassword:

                    PropertyValueCollection values = ((DirectoryEntry)p.GetUnderlyingObject()).Properties["UserFlags"];

                    if (values.Count != 0)
                    {
                        Debug.Assert(values.Count == 1);
                        Debug.Assert(values[0] is int);

                        return (SDSUtils.StatusFromAccountControl((int)values[0], PropertyNames.PwdInfoCannotChangePassword));
                    }

                    Debug.Fail("SAMStoreCtx.AccessCheck:  user entry has an empty UserFlags value");

                    GlobalDebug.WriteLineIf(GlobalDebug.Info, "SAMStoreCtx", "AccessCheck Unable to read userAccountControl");

                    break;

                default:

                    Debug.Fail("SAMStoreCtx.AccessCheck: Fell off end looking for " + targetPermission.ToString());

                    break;
            }

            return false;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:33,代码来源:SAMStoreCtx.cs

示例5: GetProperty

 public static string GetProperty(Principal principal, String property)
 {
     DirectoryEntry directoryEntry = principal.GetUnderlyingObject() as DirectoryEntry;
     if (directoryEntry.Properties.Contains(property))
     {
         return directoryEntry.Properties[property].Value.ToString();
     }
     else
     {
         return String.Empty;
     }
 }
开发者ID:cwillison94,项目名称:sar-tool,代码行数:12,代码来源:ActiveDirectory.cs

示例6: setProperty

 /// <summary>
 /// Sets the value of a directory entry property for a given AD Principal object
 /// </summary>
 /// <param name="principal"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 private static void setProperty(Principal principal, string property, string value)
 {
     try
     {
         DirectoryEntry dirEntry = principal.GetUnderlyingObject() as DirectoryEntry;
         if (dirEntry.Properties.Contains(property))
         {
             dirEntry.Properties[property].Value = value;
         }
     }
     catch (System.DirectoryServices.DirectoryServicesCOMException ex)
     {
         throw ex;
     }
 }
开发者ID:macnlinux,项目名称:userManagement,代码行数:21,代码来源:userManagement.cs

示例7: getProperty

 /// <summary>
 /// Gets the value of a directory entry property for a given AD Principal object
 /// </summary>
 /// <param name="principal"></param>
 /// <param name="property"></param>
 /// <returns></returns>
 private static String getProperty(Principal principal, string property)
 {
     try
     {
     string value;
     DirectoryEntry dirEntry = principal.GetUnderlyingObject() as DirectoryEntry;
     if (dirEntry.Properties.Contains(property))
         value = dirEntry.Properties[property].Value.ToString();
     else
         value = String.Empty;
     return value;
     }
     catch (System.DirectoryServices.DirectoryServicesCOMException ex)
     {
         throw ex;
     }
 }
开发者ID:macnlinux,项目名称:userManagement,代码行数:23,代码来源:userManagement.cs

示例8: AccessCheck

		internal override bool AccessCheck(Principal p, PrincipalAccessMask targetPermission)
		{
			PrincipalAccessMask principalAccessMask = targetPermission;
			if (principalAccessMask == PrincipalAccessMask.ChangePassword)
			{
				PropertyValueCollection item = ((DirectoryEntry)p.GetUnderlyingObject()).Properties["UserFlags"];
				if (item.Count != 0)
				{
					return SDSUtils.StatusFromAccountControl((int)item[0], "AuthenticablePrincipal.PasswordInfo.UserCannotChangePassword");
				}
			}
			return false;
		}
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:SAMStoreCtx.cs

示例9: SetProperty

        /// <summary>
        /// Sets the specified property to the specified value on the specified Principal.
        /// </summary>
        /// <param name="principal">The Principal object.</param>
        /// <param name="property">The name of the property.</param>
        /// <param name="value">The value to assign to the property.</param>
        /// <returns>True if success, false otherwise.</returns>
        public static Boolean SetProperty(Principal principal, string property, string value)
        {
            DirectoryEntry de = principal.GetUnderlyingObject() as DirectoryEntry;
            // Use PropertyLookup to get the property name in the correct format.
            string targetProperty = PropertyLookup.Instance.get(property);

            // if the property is Manager the value should be a distinguishedName but those
            // are hard to pass around in URLs if they have errant commas and escaping backslashes.
            // Instead get the dn from the value which should be a samaccountname.
            if (targetProperty == PropertyLookup.Instance.get("manager"))
            {
                value = GetDistinguishedName(value);
            }
            if (de.Properties.Contains(targetProperty))
            {
                try
                {
                    de.Properties[targetProperty][0] = value;
                    de.CommitChanges();
                }
                catch
                {
                    return false;
                }
            }
            else
            {
                try
                {
                    de.Properties[targetProperty].Add(value);
                    de.CommitChanges();
                }
                catch
                {
                    return false;
                }
            }
            return true;
        }
开发者ID:UAResLife,项目名称:AdApiService,代码行数:46,代码来源:AdToolkit.cs

示例10: GetProperty

 /// <summary>
 /// This method will return the value of the specified property if it exists in the specified Principal's
 /// underlying DirectoryEntry object.
 /// </summary>
 /// <param name="principal">The unique identifier of a Principal.</param>
 /// <param name="property">The name of the Property whose value should be returned.</param>
 /// <returns></returns>
 public static String GetProperty(Principal principal, string property)
 {
     DirectoryEntry de = principal.GetUnderlyingObject() as DirectoryEntry;
     // property is case senstive, use PropertyLookup
     string targetProperty = PropertyLookup.Instance.get(property);
     if (de.Properties.Contains(targetProperty))
         return de.Properties[targetProperty].Value.ToString();
     else
         return String.Empty;
 }
开发者ID:UAResLife,项目名称:AdApiService,代码行数:17,代码来源:AdToolkit.cs


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