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