本文整理汇总了C#中SecurityIdentifier类的典型用法代码示例。如果您正苦于以下问题:C# SecurityIdentifier类的具体用法?C# SecurityIdentifier怎么用?C# SecurityIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecurityIdentifier类属于命名空间,在下文中一共展示了SecurityIdentifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: verifyNTuser
public static string verifyNTuser(string userName)
{
DirectoryEntry dEntry = new DirectoryEntry("LDAP://ds.kycourts.net/CN=Users,DC=ds,DC=kycourts,DC=net");
DirectorySearcher dSearch = new DirectorySearcher(dEntry);
dSearch.PageSize = 6000;
dSearch.Filter = "cn="+userName;
dSearch.PropertiesToLoad.Add("cn");
dSearch.PropertiesToLoad.Add("mail");
dSearch.PropertiesToLoad.Add("objectSid");
dSearch.CacheResults = true;
if (dSearch.FindAll().Count > 0)
{
foreach (SearchResult sResultSet in dSearch.FindAll())
{
SecurityIdentifier sid = new SecurityIdentifier((byte[])sResultSet.Properties["objectSid"][0], 0);
string[] namesid = sid.ToString().Split('-');
dEntry.Close();
return sResultSet.Properties["cn"][0].ToString() + ";" + sResultSet.Properties["mail"][0].ToString() + ";" +
namesid[namesid.Length - 1].ToString();
}
}
else
{
dEntry.Close();
return "false";
}
return "false";
}
开发者ID:Ascotthowe,项目名称:Elected-Officials-Credit-Tracking,代码行数:32,代码来源:NTauthentication.cs
示例2: GetSingleStringPropertyCollectionValue
public static string GetSingleStringPropertyCollectionValue(ResultPropertyCollection props, string name)
{
try
{
if (!props.Contains(name))
{
return string.Empty;
}
ResultPropertyValueCollection pvc = props[name];
if (pvc == null || pvc.Count == 0)
{
return string.Empty;
}
if (string.Compare(name, Constants.Properties.AdProperties.ObjectSID) == 0)
{
byte[] sidInBytes = (byte[])pvc[0];
SecurityIdentifier sid = new SecurityIdentifier(sidInBytes, 0);
return Convert.ToString(sid);
}
else
{
return Convert.ToString(pvc[0]);
}
}
catch (Exception ex)
{
throw new ApplicationException(string.Format("Failed to retrieve property '{0}' from ResultPropertyCollection.", name), ex);
}
}
开发者ID:ivankhripunov,项目名称:K2NEServiceBroker,代码行数:30,代码来源:LdapHelper.cs
示例3: CreateFromSecurityIdentifier
public static ActiveDirectoryRole CreateFromSecurityIdentifier(SecurityIdentifier sid)
{
if (sid == null)
throw new ArgumentNullException("sid");
ActiveDirectoryRole role = new ActiveDirectoryRole(GetRootEntry(), new DirectoryRootQuery("objectSID", sid.ToString(), DirectoryQueryOperation.Equal));
role.Operations.Add(s_directoryGroupQuery);
ValidateRole(role);
return role;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ADRoleFactory.cs
示例4: AreSidsInSameDomain
internal static bool AreSidsInSameDomain(SecurityIdentifier sid1, SecurityIdentifier sid2)
{
if (!sid1.IsAccountSid() || !sid2.IsAccountSid())
{
return false;
}
else
{
return sid1.AccountDomainSid.Equals(sid2.AccountDomainSid);
}
}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:ADUtils.cs
示例5: CreateAdGroup
public static string CreateAdGroup(string name, string adPath)
{
string grpSid = String.Empty;
using (WindowsImpersonationContextFacade impersonationContext
= new WindowsImpersonationContextFacade(
nc))
{
//DirectoryEntry directoryEntry = new DirectoryEntry(DomainPath);
//DirectoryEntry ou = directoryEntry.Children.Find(adPath);
//DirectoryEntry group = ou.Children.Add($"CN={name}", "group");
//group.Properties["samAccountName"].Value = name;
//group.CommitChanges();
bool groupIsExist = false;
DirectoryEntry directoryEntry = new DirectoryEntry(DomainPath);
using (directoryEntry)
{
//Если пользователь существует
DirectorySearcher search = new DirectorySearcher(directoryEntry);
search.Filter = String.Format("(&(objectClass=user)(sAMAccountName={0}))", name);
SearchResult resultGroup = search.FindOne();
groupIsExist = resultGroup != null && resultGroup.Properties.Contains("sAMAccountName");
if (!groupIsExist)
{
DirectoryEntry ou = directoryEntry.Children.Find(adPath);
DirectoryEntry group = ou.Children.Add($"CN={name}", "group");
group.Properties["samAccountName"].Value = name;
group.CommitChanges();
SecurityIdentifier sid = new SecurityIdentifier((byte[])group.Properties["objectsid"][0],
0);
grpSid = sid.Value;
}
else
{
SecurityIdentifier sid = new SecurityIdentifier((byte[])resultGroup.Properties["objectsid"][0],
0);
grpSid = sid.Value;
}
}
}
return grpSid;
}
开发者ID:WakeDown,项目名称:UnitApis,代码行数:47,代码来源:AdHelper.cs
示例6: FindGroup
public static string FindGroup(SecurityIdentifier searchSid)
{
using(var ad = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"))
{
ad.Children.SchemaFilter.Add("group");
foreach(DirectoryEntry dChildEntry in ad.Children)
{
var bytes = (byte[])dChildEntry.Properties["objectSid"].Value;
var sid = new SecurityIdentifier(bytes, 0).ToString();
if(sid == searchSid.ToString())
{
return dChildEntry.Name;
}
}
}
throw new Exception("Cannot find group");
}
开发者ID:Robin--,项目名称:Warewolf,代码行数:18,代码来源:AuthorizationServiceBase.cs
示例7: GetSingleStringPropertyCollectionValue
public static string GetSingleStringPropertyCollectionValue(ResultPropertyCollection props, string name)
{
if (!props.Contains(name))
{
return string.Empty;
}
ResultPropertyValueCollection pvc = props[name];
if (pvc == null || pvc.Count == 0)
{
return string.Empty;
}
if (string.Compare(name, Constants.Properties.AdProperties.ObjectSID) == 0)
{
byte[] sidInBytes = (byte[])pvc[0];
SecurityIdentifier sid = new SecurityIdentifier(sidInBytes, 0);
return Convert.ToString(sid);
}
else
{
return pvc[0] as string;
}
}
开发者ID:dudelis,项目名称:K2NEServiceBroker,代码行数:23,代码来源:LdapHelper.cs
示例8: SetAudit
public void SetAudit(AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例9: RemoveAuditSpecific
public void RemoveAuditSpecific(SecurityIdentifier sid, ObjectAuditRule rule);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例10: RemoveAudit
public bool RemoveAudit(SecurityIdentifier sid, ObjectAuditRule rule);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例11: ObjectAce
public ObjectAce(AceFlags aceFlags, AceQualifier qualifier, int accessMask, SecurityIdentifier sid, ObjectAceFlags flags, Guid type, Guid inheritedType, bool isCallback, byte[] opaque);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例12: SetAccess
public void SetAccess(AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例13: RemoveAccessSpecific
public void RemoveAccessSpecific(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例14: CheckWriteAccessEnabled
public static bool CheckWriteAccessEnabled(string path, string sid)
{
// get file or directory security object
FileSystemSecurity security = GetFileSystemSecurity(path);
if (security == null)
return false;
if (sid == null)
return false;
AuthorizationRuleCollection rules = security.GetAccessRules(true, true, typeof(SecurityIdentifier));
SecurityIdentifier identity = new SecurityIdentifier(sid);
foreach (FileSystemAccessRule rule in rules)
{
if (rule.IdentityReference == identity
&& rule.AccessControlType == AccessControlType.Allow
&& (rule.FileSystemRights & FileSystemRights.Write) == FileSystemRights.Write)
return true;
}
return false;
}
开发者ID:jordan49,项目名称:websitepanel,代码行数:21,代码来源:SecurityUtils.cs
示例15: CompoundAce
public CompoundAce(AceFlags flags, int accessMask, CompoundAceType compoundAceType, SecurityIdentifier sid);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例16: RemoveAccess
public bool RemoveAccess(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例17: GrantNtfsPermissionsBySid
public static void GrantNtfsPermissionsBySid(string path, string sid,
NTFSPermission permissions, bool inheritParentPermissions,
bool preserveOriginalPermissions)
{
// get file or directory security object
FileSystemSecurity security = GetFileSystemSecurity(path);
if (security == null)
return;
FileSystemRights rights = FileSystemRights.Read;
if (permissions == NTFSPermission.FullControl)
rights = FileSystemRights.FullControl;
else if (permissions == NTFSPermission.Modify)
rights = FileSystemRights.Modify;
else if (permissions == NTFSPermission.Write)
rights = FileSystemRights.Write;
else if (permissions == NTFSPermission.Read && security is DirectorySecurity)
rights = FileSystemRights.ReadAndExecute;
else if (permissions == NTFSPermission.Read && security is FileSecurity)
rights = FileSystemRights.Read;
SecurityIdentifier identity = new SecurityIdentifier(sid);
if (!preserveOriginalPermissions)
security = CreateFileSystemSecurity(path);
else
security.RemoveAccessRuleAll(new FileSystemAccessRule(identity,
FileSystemRights.Read, AccessControlType.Allow));
if (!inheritParentPermissions)
security.SetAccessRuleProtection(true, inheritParentPermissions);
else
security.SetAccessRuleProtection(false, true);
InheritanceFlags flags = security is FileSecurity ? InheritanceFlags.None
: InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit;
// change DACL
FileSystemAccessRule rule = new FileSystemAccessRule(
identity, rights,
flags,
PropagationFlags.None,
AccessControlType.Allow);
// add/modify rule
security.AddAccessRule(rule);
// set security object
SetFileSystemSecurity(path, security);
}
开发者ID:jordan49,项目名称:websitepanel,代码行数:50,代码来源:SecurityUtils.cs
示例18: GetSpnSid
internal SecurityIdentifier GetSpnSid()
{
if (!this.hasSpnSidBeenComputed)
{
lock (this.thisLock)
{
if (!this.hasSpnSidBeenComputed)
{
string spn = null;
try
{
if (ClaimTypes.Dns.Equals(base.IdentityClaim.ClaimType))
{
spn = "host/" + ((string) base.IdentityClaim.Resource);
}
else
{
spn = (string) base.IdentityClaim.Resource;
}
if (spn != null)
{
spn = spn.Replace("*", @"\*").Replace("(", @"\(").Replace(")", @"\)");
}
using (DirectorySearcher searcher = new DirectorySearcher(GetDirectoryEntry()))
{
searcher.CacheResults = true;
searcher.ClientTimeout = SpnLookupTime;
searcher.Filter = "(&(objectCategory=Computer)(objectClass=computer)(servicePrincipalName=" + spn + "))";
searcher.PropertiesToLoad.Add("objectSid");
SearchResult result = searcher.FindOne();
if (result != null)
{
byte[] binaryForm = (byte[]) result.Properties["objectSid"][0];
this.spnSid = new SecurityIdentifier(binaryForm, 0);
}
else
{
SecurityTraceRecordHelper.TraceSpnToSidMappingFailure(spn, null);
}
}
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
if ((exception is NullReferenceException) || (exception is SEHException))
{
throw;
}
SecurityTraceRecordHelper.TraceSpnToSidMappingFailure(spn, exception);
}
finally
{
this.hasSpnSidBeenComputed = true;
}
}
}
}
return this.spnSid;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:62,代码来源:SpnEndpointIdentity.cs
示例19: CommonAce
public CommonAce(AceFlags flags, AceQualifier qualifier, int accessMask, SecurityIdentifier sid, bool isCallback, byte[] opaque);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
示例20: RawSecurityDescriptor
public RawSecurityDescriptor(ControlFlags flags, SecurityIdentifier owner, SecurityIdentifier group, RawAcl systemAcl, RawAcl discretionaryAcl);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs
注:本文中的SecurityIdentifier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论