Opc.Ua.Configuration.AccountInfo.GetIdentityReference C# (CSharp) Method

GetIdentityReference() public method

Returns the identity reference for the account.
public GetIdentityReference ( ) : IdentityReference
return System.Security.Principal.IdentityReference
        public IdentityReference GetIdentityReference()
        {
            string domain = m_domain;

            if (String.Compare(domain, System.Net.Dns.GetHostName(), true) == 0)
            {
                domain = null;
            }

            if (!String.IsNullOrEmpty(m_name))
            {
                if (String.IsNullOrEmpty(domain))
                {
                    return new NTAccount(m_name);
                }

                return new NTAccount(domain, m_name);
            }

            if (!String.IsNullOrEmpty(m_sid))
            {
                return new SecurityIdentifier(m_sid);
            }

            return null;
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public bool ShowDialog(ApplicationAccessRule accessRule)
        {
            AccessTypeCB.SelectedItem = accessRule.RuleType;
            IdentityNameTB.Text       = accessRule.IdentityName;
            m_identity = accessRule.IdentityReference;

            if (m_identity == null)
            {
                AccountInfo account = AccountInfo.Create(IdentityNameTB.Text);

                if (account != null)
                {
                    m_identity = account.GetIdentityReference();
                }
            }

            if (accessRule.Right != ApplicationAccessRight.None)
            {
                AccessRightCB.SelectedItem = accessRule.Right;
            }

            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            accessRule.RuleType          = (AccessControlType)AccessTypeCB.SelectedItem;
            accessRule.Right             = (ApplicationAccessRight)AccessRightCB.SelectedItem;
            accessRule.IdentityReference = m_identity;

            return(true);
        }
All Usage Examples Of Opc.Ua.Configuration.AccountInfo::GetIdentityReference