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


C# SecurityIdentifier类代码示例

本文整理汇总了C#中SecurityIdentifier的典型用法代码示例。如果您正苦于以下问题:C# SecurityIdentifier类的具体用法?C# SecurityIdentifier怎么用?C# SecurityIdentifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecurityIdentifier类属于命名空间,在下文中一共展示了SecurityIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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