Add() public method

Adds the specified attribute to this set if it is not already present. If an attribute with the same name already exists in the set then the specified attribute will not be added.
public Add ( object attr ) : bool
attr object Object of type LdapAttribute /// ///
return bool
Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if ( args.Length != 5)
            {
            Console.WriteLine("Usage:   mono AddEntry <host name> <ldap port>  <login dn>" + " <password> <container>");
            Console.WriteLine("Example: mono AddEntry Acme.com 389"  + " \"cn=admin,o=Acme\"" + " secret \"ou=sales,o=Acme\"");
            return;
            }

            string ldapHost = args[0];
            int ldapPort = System.Convert.ToInt32(args[1]);
            String loginDN  = args[2];
            String password = args[3];
            String containerName = args[4];

            try
            {
            LdapAttributeSet attributeSet = new LdapAttributeSet();
            attributeSet.Add(	new LdapAttribute(
                                "objectclass", "inetOrgPerson"));
                                attributeSet.Add( new LdapAttribute("cn",
                                new string[]{"James Smith", "Jim Smith", "Jimmy Smith"}));
            attributeSet.Add(	new LdapAttribute("givenname",
                                 "James"));
            attributeSet.Add(	new LdapAttribute("sn", "Smith"));
            attributeSet.Add(	new LdapAttribute("telephonenumber","1 801 555 1212"));
            attributeSet.Add(	new LdapAttribute("mail", "*****@*****.**"));
            attributeSet.Add(	new LdapAttribute("userpassword","newpassword"));

            string  dn  = "cn=KSmith," + containerName;
            LdapEntry newEntry = new LdapEntry( dn, attributeSet );
            LdapConnection conn= new LdapConnection();
            Console.WriteLine("Connecting to:" + ldapHost);
            conn.Connect(ldapHost,ldapPort);
            conn.Bind(loginDN,password);
            conn.Add( newEntry );
            Console.WriteLine("Entry:" + dn + "  Added Successfully");
            conn.Disconnect();
            }
            catch(LdapException e)
            {
            Console.WriteLine("Error:" + e.LdapErrorMessage);
            return;
            }
            catch(Exception e)
            {
            Console.WriteLine("Error:" + e.Message);
            return;
            }
        }
Ejemplo n.º 2
0
        void createUser(string dn, string name, string pass, string sid, 
					 string flags, string uid, string gid, 
					 string urid, string grid, string gecos)
        {
            LdapAttributeSet lset = new LdapAttributeSet ();
            lset.Add (new LdapAttribute ("objectclass", new string[] {"inetOrgPerson", "sambaSAMAccount", "posixAccount", "shadowAccount"}));
            lset.Add (new LdapAttribute ("cn", name));
            lset.Add (new LdapAttribute ("sn", name));
            lset.Add (new LdapAttribute ("gidNumber", gid));
            lset.Add (new LdapAttribute ("uid", name));
            lset.Add (new LdapAttribute ("uidNumber", uid));
            lset.Add (new LdapAttribute ("homeDirectory", "/dev/null"));
            lset.Add (new LdapAttribute ("sambaPwdLastSet", "0"));
            lset.Add (new LdapAttribute ("sambaLogonTime", "0"));
            lset.Add (new LdapAttribute ("sambaLogoffTime", "2147483647"));
            lset.Add (new LdapAttribute ("sambaKickoffTime", "2147483647"));
            lset.Add (new LdapAttribute ("sambaPwdCanChange", "0"));
            lset.Add (new LdapAttribute ("sambaPwdMustChange", "2147483647"));
            lset.Add (new LdapAttribute ("sambaPrimaryGroupSID", sid + "-" + grid));
            lset.Add (new LdapAttribute ("sambaLMPassword", pass));
            lset.Add (new LdapAttribute ("sambaNTPassword", pass));
            lset.Add (new LdapAttribute ("sambaAcctFlags", flags));
            lset.Add (new LdapAttribute ("sambaSID", sid + "-" + urid));
            lset.Add (new LdapAttribute ("loginShell", "/bin/false"));
            lset.Add (new LdapAttribute ("gecos", gecos));

            LdapEntry entry = new LdapEntry (dn, lset);
            Connection conn = GetCurrentConnection ();
            Util.AddEntry (conn, entry);
        }
Ejemplo n.º 3
0
        void createOU(string dn)
        {
            LdapAttributeSet lset = new LdapAttributeSet ();
            lset.Add (new LdapAttribute ("objectclass", new string[] {"organizationalUnit"}));
            lset.Add (new LdapAttribute ("ou", getCN(dn)));

            LdapEntry entry = new LdapEntry (dn, lset);

            Connection conn = GetCurrentConnection ();
            Util.AddEntry (conn, entry);
        }
Ejemplo n.º 4
0
        void createGroup(string dn, string gid, string desc, 
					  string sid, string grid, string gtype, 
					  string memberuid)
        {
            LdapAttributeSet lset = new LdapAttributeSet ();
            lset.Add (new LdapAttribute ("objectclass", new string[] {"posixGroup", "sambaGroupMapping"}));
            lset.Add (new LdapAttribute ("gidNumber", gid));
            lset.Add (new LdapAttribute ("cn", getCN(dn)));
            lset.Add (new LdapAttribute ("description", desc));
            lset.Add (new LdapAttribute ("sambaSID", sid + "-" + grid));
            lset.Add (new LdapAttribute ("sambaGroupType", gtype));
            lset.Add (new LdapAttribute ("displayName", getCN(dn)));

            if (memberuid != "")
                lset.Add (new LdapAttribute ("memberUid", memberuid));

            LdapEntry entry = new LdapEntry (dn, lset);
            Connection conn = GetCurrentConnection ();
            Util.AddEntry (conn, entry);
        }
Ejemplo n.º 5
0
        void createDomain(string dn, string domain, string sid)
        {
            LdapAttributeSet lset = new LdapAttributeSet ();
            lset.Add (new LdapAttribute ("objectclass", new string[] {"sambaDomain"}));
            lset.Add (new LdapAttribute ("sambaDomainName", domain));
            lset.Add (new LdapAttribute ("sambaSID", sid));

            LdapEntry entry = new LdapEntry (dn, lset);
            Connection conn = GetCurrentConnection ();
            Util.AddEntry (conn, entry);
        }
Ejemplo n.º 6
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();

            TreeIter iter;

            if (primaryGroupComboBox.GetActiveIter (out iter)) {
                string pg = (string) primaryGroupComboBox.Model.GetValue (iter, 0);
                string gid = getGidNumber(pg);
                if (gid != null)
                    aset.Add (new LdapAttribute ("gidNumber", gid));
            }

            aset.Add (new LdapAttribute ("givenName", firstNameEntry.Text));
            aset.Add (new LdapAttribute ("sn", lastNameEntry.Text));
            aset.Add (new LdapAttribute ("uid", usernameEntry.Text));
            aset.Add (new LdapAttribute ("uidNumber", uidSpinButton.Value.ToString()));

            if (!dontRequirePasswords)
                aset.Add (new LdapAttribute ("userPassword", passwordEntry.Text));

            aset.Add (new LdapAttribute ("loginShell", shellEntry.Text));
            aset.Add (new LdapAttribute ("homeDirectory", homeDirEntry.Text));
            aset.Add (new LdapAttribute ("displayName", displayNameEntry.Text));
            aset.Add (new LdapAttribute ("cn", displayNameEntry.Text));
            aset.Add (new LdapAttribute ("gecos", displayNameEntry.Text));

            if (initialsEntry.Text != "")
                aset.Add (new LdapAttribute ("initials", initialsEntry.Text));

            if (enableSambaButton.Active) {

                aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixaccount", "shadowaccount","inetorgperson", "person", "sambaSAMAccount"}));

                int user_rid = Convert.ToInt32 (uidSpinButton.Value) * 2 + 1000;
                LdapAttribute[] tmp = Util.CreateSambaAttributes (user_rid, smbSID, smbLM, smbNT);
                foreach (LdapAttribute a in tmp)
                    aset.Add (a);

            } else {

                if (dontRequirePasswords)
                    aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixaccount", "inetorgperson", "person"}));
                else
                    aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixaccount", "shadowaccount","inetorgperson", "person"}));
            }

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
		/// <summary> Creates a new attribute set containing only the attributes that have
		/// the specified subtypes.
		/// 
		/// For example, suppose an attribute set contains the following
		/// attributes:
		/// 
		/// <ul>
		/// <li>    cn</li>
		/// <li>    cn;lang-ja</li>
		/// <li>    sn;phonetic;lang-ja</li>
		/// <li>    sn;lang-us</li>
		/// </ul>
		/// 
		/// Calling the <code>getSubset</code> method and passing lang-ja as the
		/// argument, the method returns an attribute set containing the following
		/// attributes:
		/// 
		/// <ul>
		/// <li>cn;lang-ja</li>
		/// <li>sn;phonetic;lang-ja</li>
		/// </ul>
		/// 
		/// </summary>
		/// <param name="subtype">   Semi-colon delimited list of subtypes to include. For
		/// example:
		/// <ul>
		/// <li> "lang-ja" specifies only Japanese language subtypes</li>
		/// <li> "binary" specifies only binary subtypes</li>
		/// <li> "binary;lang-ja" specifies only Japanese language subtypes
		/// which also are binary</li>
		/// </ul>
		/// 
		/// Note: Novell eDirectory does not currently support language subtypes.
		/// It does support the "binary" subtype.
		/// 
		/// </param>
		/// <returns> An attribute set containing the attributes that match the
		/// specified subtype.
		/// </returns>
		public virtual LdapAttributeSet getSubset(System.String subtype)
		{
			
			// Create a new tempAttributeSet
			LdapAttributeSet tempAttributeSet = new LdapAttributeSet();
			System.Collections.IEnumerator i = this.GetEnumerator();
			
			// Cycle throught this.attributeSet
			while (i.MoveNext())
			{
				LdapAttribute attr = (LdapAttribute) i.Current;
				
				// Does this attribute have the subtype we are looking for. If
				// yes then add it to our AttributeSet, else next attribute
				if (attr.hasSubtype(subtype))
					tempAttributeSet.Add(attr.Clone());
			}
			return tempAttributeSet;
		}
		private void CommitEntry()
		{
			if(!Nflag)
			{
				System.Collections.ArrayList modList = new System.Collections.ArrayList();
				System.Collections.IDictionaryEnumerator id = Properties.GetEnumerator();
				while(id.MoveNext())
				{
					string attribute=(string)id.Key;
					LdapAttribute attr=null;
					if(Properties[attribute].Mbit)
					{
						if(Properties[attribute].Count==1)
						{
							String val = (String)Properties[attribute].Value;
							attr = new LdapAttribute( attribute , val);
						}
						else
						{
							Object[] vals=(Object [])Properties[attribute].Value;
							String[] aStrVals= new String[Properties[attribute].Count];
							Array.Copy(vals,0,aStrVals,0,Properties[attribute].Count);
							attr = new LdapAttribute( attribute , aStrVals);
						}
						modList.Add( new LdapModification(LdapModification.REPLACE, attr));
						Properties[attribute].Mbit=false;
					}
				}
				if (modList.Count > 0) {
					LdapModification[] mods = new LdapModification[modList.Count]; 	
					Type mtype=Type.GetType("System.DirectoryServices.LdapModification");
					mods = (LdapModification[])modList.ToArray(typeof(LdapModification));
					ModEntry(mods);
				}
			}
			else
			{
				LdapAttributeSet attributeSet = new LdapAttributeSet();
				System.Collections.IDictionaryEnumerator id = Properties.GetEnumerator();
				while(id.MoveNext())
				{
					string attribute=(string)id.Key;
					if(Properties[attribute].Count==1)
					{
						String val = (String)Properties[attribute].Value;
						attributeSet.Add(new LdapAttribute(attribute, val));                
					}
					else
					{
						Object[] vals=(Object [])Properties[attribute].Value;
						String[] aStrVals= new String[Properties[attribute].Count];
						Array.Copy(vals,0,aStrVals,0,Properties[attribute].Count);
						attributeSet.Add( new LdapAttribute( attribute , aStrVals));
					}
				}
				LdapEntry newEntry = new LdapEntry( Fdn, attributeSet );
				conn.Add( newEntry );
				Nflag = false;
			}
		}
Ejemplo n.º 9
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("cn", groupNameEntry.Text));
            aset.Add (new LdapAttribute ("description", descriptionEntry.Text));
            aset.Add (new LdapAttribute ("gidNumber", groupIDSpinButton.Value.ToString()));

            if (currentMembers.Count >= 1)
                aset.Add (new LdapAttribute ("memberuid", currentMembers.ToArray()));

            if (enableSambaButton.Active || isSamba) {

                aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixGroup", "sambaGroupMapping"}));
                aset.Add (new LdapAttribute ("sambaGroupType", "2"));

                int grid = Convert.ToInt32 (groupIDSpinButton.Value) * 2 + 1001;
                smbSID = conn.Data.GetLocalSID ();
                aset.Add (new LdapAttribute ("sambaSID", String.Format ("{0}-{1}", conn.Data.GetLocalSID (), grid)));

            } else {
                aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixGroup"}));
            }

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 10
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "ipHost", "device"}));
            aset.Add (new LdapAttribute ("cn", hostNameEntry.Text));
            aset.Add (new LdapAttribute ("ipHostNumber", ipEntry.Text));
            aset.Add (new LdapAttribute ("description", descriptionEntry.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 11
0
    // add dynamic group entry
    public static bool addDynamicGroupEntry( LdapConnection lc,
        String loginDN, String entryDN, String queryURL)
    {
        bool status = true;
        LdapAttributeSet  attributeSet = new LdapAttributeSet();

        //The objectclass "dynamicGroup is used to create dynamic group entries
        attributeSet.Add( new LdapAttribute( "objectclass", "dynamicGroup" ));

        /* The memberQueryURL attribute describes the membership of the list
         * using an LdapURL, which is defined in RFC2255
         */
        attributeSet.Add( new LdapAttribute( "memberQueryURL", queryURL ) );

        /* Set the identity to use for the implied search.  loginDN is used
         * as the dgIdentity in this sample.
         */
        attributeSet.Add( new LdapAttribute( "dgIdentity", loginDN ) );

        LdapEntry newEntry = new LdapEntry( entryDN, attributeSet );

        try
        {
            lc.Add( newEntry );
            Console.WriteLine("\tEntry: " + entryDN + " added successfully." );
        }
        catch( LdapException e )
        {
            Console.WriteLine( "\t\tFailed to add dynamic group entry " +
                       entryDN);
            Console.WriteLine( "Error: " + e.ToString() );
            status = false;
        }
        return status;
    }
Ejemplo n.º 12
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "group"}));
            aset.Add (new LdapAttribute ("cn", groupNameEntry.Text));
            aset.Add (new LdapAttribute ("description", descriptionEntry.Text));
            aset.Add (new LdapAttribute ("sAMAccountName", groupNameEntry.Text));
            aset.Add (new LdapAttribute ("groupType", "-2147483646"));

            if (currentMembers.Count >= 1)
                aset.Add (new LdapAttribute ("member", currentMembers.ToArray()));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 13
0
        /// <summary>Adds an entry to the directory
        /// 
        /// </summary>
        /// <param name="dn">The distinguished name of the new entry.</param>
        /// <param name="attributes">An arraylist of string attributes for the 
        /// new ldap entry.</param>
        public void Add(string dn, List<LdapAttribute> attributes)
        {
            Log.Debug ("START Connection.Add ()");
            Log.Debug ("dn: {0}", dn);

            LdapAttributeSet attributeSet = new LdapAttributeSet();

            foreach (LdapAttribute attr in attributes) {

                foreach (string v in attr.StringValueArray)
                    Log.Debug ("{0}:{1}", attr.Name, v);

                attributeSet.Add (attr);
            }

            LdapEntry newEntry = new LdapEntry( dn, attributeSet );
            Add (newEntry);

            Log.Debug ("END Connection.Add ()");
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
0
        /// <summary>Copy a directory entry
        /// </summary>
        /// <param name="oldDN">Distinguished name of the entry to copy</param>
        /// <param name="newRDN">New name for entry</param>
        /// <param name="parentDN">Parent name</param>
        public void Copy(string oldDN, string newRDN, string parentDN)
        {
            string newDN = string.Format ("{0},{1}", newRDN, parentDN);

            LdapEntry[] entry = Search (oldDN, LdapConnection.SCOPE_BASE, "objectclass=*", null);
            if (!(entry.Length > 0))
                return;

            LdapEntry oldEntry = entry[0];
            LdapAttributeSet attributeSet = new LdapAttributeSet();

            foreach (LdapAttribute attr in oldEntry.getAttributeSet()) {
                LdapAttribute newAttr = new LdapAttribute (attr);
                attributeSet.Add (newAttr);
            }

            LdapEntry le = new LdapEntry (newDN, attributeSet);
            conn.Add (le);
        }
Ejemplo n.º 16
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("objectClass", new string[] {"computer"}));
            aset.Add (new LdapAttribute ("cn", computerNameLabel.Text));
            aset.Add (new LdapAttribute ("description", descriptionEntry.Text));
            aset.Add (new LdapAttribute ("dNSHostName", dnsNameEntry.Text));
            aset.Add (new LdapAttribute ("operatingSystem", osNameEntry.Text));
            aset.Add (new LdapAttribute ("operatingSystemVersion", osVersionEntry.Text));
            aset.Add (new LdapAttribute ("operatingSystemServicePack", osServicePackEntry.Text));
            aset.Add (new LdapAttribute ("location", locationEntry.Text));
            aset.Add (new LdapAttribute ("managedBy", manNameEntry.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 17
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "person", "organizationalPerson", "contact" }));
            aset.Add (new LdapAttribute ("givenName", gnFirstNameEntry.Text));
            aset.Add (new LdapAttribute ("initials", gnInitialsEntry.Text));
            aset.Add (new LdapAttribute ("sn", gnLastNameEntry.Text));
            aset.Add (new LdapAttribute ("displayName", gnDisplayName.Text));
            aset.Add (new LdapAttribute ("cn", gnDisplayName.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
		private void CommitEntry()
		{
			PropertyCollection properties = GetProperties(false);
			if(!Nflag)
			{
				System.Collections.ArrayList modList = new System.Collections.ArrayList();
				foreach (string attribute in properties.PropertyNames)
				{
					LdapAttribute attr=null;
					if (properties [attribute].Mbit)
					{
						switch (properties [attribute].Count) {
							case 0:
								attr = new LdapAttribute (attribute, new string [0]);
								modList.Add (new LdapModification (LdapModification.DELETE, attr));
								break;
							case 1:
								string val = (string) properties [attribute].Value;
								attr = new LdapAttribute (attribute, val);
								modList.Add (new LdapModification (LdapModification.REPLACE, attr));
								break;
							default:
								object [] vals = (object [])properties [attribute].Value;
								string [] aStrVals = new string [properties [attribute].Count];
								Array.Copy (vals, 0, aStrVals, 0, properties [attribute].Count);
								attr = new LdapAttribute (attribute, aStrVals);
								modList.Add (new LdapModification (LdapModification.REPLACE, attr));
								break;
						}
						properties [attribute].Mbit=false;
					}
				}
				if (modList.Count > 0) {
					LdapModification[] mods = new LdapModification[modList.Count]; 	
					Type mtype = typeof (LdapModification);
					mods = (LdapModification[])modList.ToArray(mtype);
					ModEntry(mods);
				}
			}
			else
			{
				LdapAttributeSet attributeSet = new LdapAttributeSet();
				foreach (string attribute in properties.PropertyNames)
				{
					if (properties [attribute].Count == 1)
					{
						string val = (string) properties [attribute].Value;
						attributeSet.Add(new LdapAttribute(attribute, val));                
					}
					else
					{
						object[] vals = (object []) properties [attribute].Value;
						string[] aStrVals = new string [properties [attribute].Count];
						Array.Copy (vals,0,aStrVals,0,properties [attribute].Count);
						attributeSet.Add( new LdapAttribute( attribute , aStrVals));
					}
				}
				LdapEntry newEntry = new LdapEntry( Fdn, attributeSet );
				conn.Add( newEntry );
				Nflag = false;
			}
		}
Ejemplo n.º 19
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();

            // General
            aset.Add (new LdapAttribute ("cn", fullnameLabel.Text));
            aset.Add (new LdapAttribute ("displayName", fullnameLabel.Text));
            aset.Add (new LdapAttribute ("gecos", fullnameLabel.Text));
            aset.Add (new LdapAttribute ("givenName", firstNameEntry.Text));
            aset.Add (new LdapAttribute ("initials", initialsEntry.Text));
            aset.Add (new LdapAttribute ("sn", lastNameEntry.Text));
            aset.Add (new LdapAttribute ("description", descriptionEntry.Text));
            aset.Add (new LdapAttribute ("physicalDeliveryOfficeName", officeEntry.Text));
            aset.Add (new LdapAttribute ("mail", mailEntry.Text));
            aset.Add (new LdapAttribute ("telephoneNumber", phoneEntry.Text));

            // Account
            aset.Add (new LdapAttribute ("uid", usernameEntry.Text));
            aset.Add (new LdapAttribute ("uidNumber", uidSpinButton.Value.ToString()));
            aset.Add (new LdapAttribute ("homeDirectory", homeDirEntry.Text));
            aset.Add (new LdapAttribute ("loginShell", shellEntry.Text));

            if (passChanged)
                aset.Add (new LdapAttribute ("userPassword", pass));
            else {
                aset.Add (new LdapAttribute ("userPassword", conn.Data.GetAttributeValueFromEntry (currentEntry, "userPassword")));
            }

            if (smbEnableSambaButton.Active || isSamba) {

                aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixaccount", "shadowaccount","inetorgperson", "person", "sambaSAMAccount"}));

                int user_rid = Convert.ToInt32 (uidSpinButton.Value) * 2 + 1000;
                LdapAttribute[] tmp = Util.CreateSambaAttributes (user_rid, conn.Data.GetLocalSID (), smbLM, smbNT);
                foreach (LdapAttribute a in tmp)
                    aset.Add (a);

                aset.Add (new LdapAttribute ("sambaProfilePath", smbProfilePathEntry.Text));
                aset.Add (new LdapAttribute ("sambaHomePath", smbHomePathEntry.Text));
                aset.Add (new LdapAttribute ("sambaHomeDrive", smbHomeDriveEntry.Text));
                aset.Add (new LdapAttribute ("sambaLogonScript", smbLoginScriptEntry.Text));

                double d = 0;
                if (smbExpireEntry.Text != "") {
                    d = Util.GetDateTime (smbExpireEntry.Text);
                    aset.Add (new LdapAttribute ("sambaKickoffTime", d.ToString()));
                }

                if (smbCanChangePwdEntry.Text != "") {
                    d = Util.GetDateTime (smbCanChangePwdEntry.Text);
                    aset.Add (new LdapAttribute ("sambaPwdCanChange", d.ToString()));
                }

                if (smbMustChangePwdEntry.Text != "") {
                    d = Util.GetDateTime (smbMustChangePwdEntry.Text);
                    aset.Add (new LdapAttribute ("sambaPwdMustChange", d.ToString()));
                }

            } else {

                aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "posixaccount", "shadowaccount","inetorgperson", "person"}));
            }

            // Groups
            string gid = getGidNumber(primaryGroupLabel.Text);
            if (gid != null) {
                aset.Add (new LdapAttribute ("gidNumber", gid));
            } else {
                LdapAttribute la = currentEntry.getAttribute ("gidNumber");
                aset.Add (new LdapAttribute ("gidNumber", la.StringValue));
            }

            // Address
            aset.Add (new LdapAttribute ("street", adStreetTextView.Buffer.Text));
            aset.Add (new LdapAttribute ("l", adCityEntry.Text));
            aset.Add (new LdapAttribute ("st", adStateEntry.Text));
            aset.Add (new LdapAttribute ("postalCode", adZipEntry.Text));
            aset.Add (new LdapAttribute ("postOfficeBox", adPOBoxEntry.Text));

            // Telephones
            aset.Add (new LdapAttribute ("facsimileTelephoneNumber", tnFaxEntry.Text));
            aset.Add (new LdapAttribute ("pager", tnPagerEntry.Text));
            aset.Add (new LdapAttribute ("mobile", tnMobileEntry.Text));
            aset.Add (new LdapAttribute ("homePhone", tnHomeEntry.Text));
            aset.Add (new LdapAttribute ("ipPhone", tnIPPhoneEntry.Text));

            // Organization
            aset.Add (new LdapAttribute ("title", ozTitleEntry.Text));
            aset.Add (new LdapAttribute ("departmentNumber", ozDeptEntry.Text));
            aset.Add (new LdapAttribute ("o", ozCompanyEntry.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 20
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "person", "organizationalPerson", "contact" }));
            aset.Add (new LdapAttribute ("givenName", gnFirstNameEntry.Text));
            aset.Add (new LdapAttribute ("initials", gnInitialsEntry.Text));
            aset.Add (new LdapAttribute ("sn", gnLastNameEntry.Text));
            aset.Add (new LdapAttribute ("displayName", gnDisplayName.Text));
            aset.Add (new LdapAttribute ("cn", gnDisplayName.Text));
            aset.Add (new LdapAttribute ("wWWHomePage", gnWebPageEntry.Text));
            aset.Add (new LdapAttribute ("physicalDeliveryOfficeName", gnOfficeEntry.Text));
            aset.Add (new LdapAttribute ("mail", gnEmailEntry.Text));
            aset.Add (new LdapAttribute ("description", gnDescriptionEntry.Text));
            aset.Add (new LdapAttribute ("street", adStreetTextView.Buffer.Text));
            aset.Add (new LdapAttribute ("l", adCityEntry.Text));
            aset.Add (new LdapAttribute ("st", adStateEntry.Text));
            aset.Add (new LdapAttribute ("postalCode", adZipEntry.Text));
            aset.Add (new LdapAttribute ("postOfficeBox", adPOBoxEntry.Text));
            aset.Add (new LdapAttribute ("co", adCountryEntry.Text));
            aset.Add (new LdapAttribute ("telephoneNumber", gnTelephoneNumberEntry.Text));
            aset.Add (new LdapAttribute ("facsimileTelephoneNumber", tnFaxEntry.Text));
            aset.Add (new LdapAttribute ("pager", tnPagerEntry.Text));
            aset.Add (new LdapAttribute ("mobile", tnMobileEntry.Text));
            aset.Add (new LdapAttribute ("homePhone", tnHomeEntry.Text));
            aset.Add (new LdapAttribute ("ipPhone", tnIPPhoneEntry.Text));
            aset.Add (new LdapAttribute ("title", ozTitleEntry.Text));
            aset.Add (new LdapAttribute ("department", ozDeptEntry.Text));
            aset.Add (new LdapAttribute ("company", ozCompanyEntry.Text));
            aset.Add (new LdapAttribute ("streetAddress", adStreetTextView.Buffer.Text));
            aset.Add (new LdapAttribute ("info", tnNotesTextView.Buffer.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }
Ejemplo n.º 21
0
        LdapEntry CreateEntry(string dn)
        {
            LdapAttributeSet aset = new LdapAttributeSet();
            string fullName = String.Format ("{0} {1}", firstNameEntry.Text, lastNameEntry.Text);
            aset.Add (new LdapAttribute ("cn", fullName));
            aset.Add (new LdapAttribute ("gecos", fullName));
            aset.Add (new LdapAttribute ("objectClass", new string[] {"top", "person", "organizationalPerson","user"}));
            aset.Add (new LdapAttribute ("givenName", firstNameEntry.Text));
            aset.Add (new LdapAttribute ("sn", lastNameEntry.Text));
            aset.Add (new LdapAttribute ("userPrincipalName", upnEntry.Text));
            aset.Add (new LdapAttribute ("sAMAccountName", usernameEntry.Text));
            aset.Add (new LdapAttribute ("userAccountControl", userAC.ToString()));
            aset.Add (new LdapAttribute ("displayName", displayNameEntry.Text));
            aset.Add (new LdapAttribute ("initials", initialsEntry.Text));

            LdapEntry newEntry = new LdapEntry (dn, aset);
            return newEntry;
        }