예제 #1
0
        public void OnOkClicked(object o, EventArgs args)
        {
            string           dn   = String.Format("{0},{1}", rdnEntry.Text, browseButton.Label);
            LdapAttributeSet lset = new LdapAttributeSet();

            foreach (object[] row in attrListStore)
            {
                string n = (string)row[0];
                string v = (string)row[1];

                if (n == null || v == null || v == "")
                {
                    continue;
                }

                if (n.ToLower() == "objectclass")
                {
                    if (objAttr == null)
                    {
                        objAttr = new LdapAttribute(n, v);
                    }
                    else
                    {
                        objAttr.addValue(v);
                    }
                }
                else
                {
                    LdapAttribute attr = new LdapAttribute(n, v);
                    lset.Add(attr);
                }
            }

            lset.Add(objAttr);

            LdapEntry entry = new LdapEntry(dn, lset);

            if (!Util.AddEntry(conn, entry))
            {
                errorOccured = true;
            }
            else
            {
                errorOccured = false;
            }
        }
예제 #2
0
        void RunViewerPlugin(AttributeViewPlugin avp, string attributeName)
        {
            LdapEntry     le = conn.Data.GetEntry(currentDN);
            LdapAttribute la = le.getAttribute(attributeName);

            bool existing = false;

            if (la != null)
            {
                existing = true;
            }

            LdapAttribute newla = new LdapAttribute(attributeName);

            switch (avp.DataType)
            {
            case ViewerDataType.Binary:
                if (existing)
                {
                    avp.OnActivate(attributeName, SupportClass.ToByteArray(la.ByteValue));
                }
                else
                {
                    avp.OnActivate(attributeName, new byte[0]);
                }
                break;

            case ViewerDataType.String:
                if (existing)
                {
                    avp.OnActivate(attributeName, la.StringValue);
                }
                else
                {
                    avp.OnActivate(attributeName, "");
                }
                break;
            }

            if (avp.ByteValue != null)
            {
                newla.addBase64Value(System.Convert.ToBase64String(avp.ByteValue, 0, avp.ByteValue.Length));
            }
            else if (avp.StringValue != null)
            {
                newla.addValue(avp.StringValue);
            }
            else
            {
                return;
            }

            LdapModification lm;

            if (existing)
            {
                lm = new LdapModification(LdapModification.REPLACE, newla);
            }
            else
            {
                lm = new LdapModification(LdapModification.ADD, newla);
            }

            List <LdapModification> modList = new List <LdapModification> ();

            modList.Add(lm);
            Util.ModifyEntry(conn, currentDN, modList.ToArray());

            this.Show(conn, conn.Data.GetEntry(currentDN), displayAll);
        }