/// <summary> /// Inserts a new user account entry into the specified feed. /// </summary> /// <param name="feed">the feed into which this entry should be inserted</param> /// <param name="entry">the entry to insert</param> /// <returns>the inserted entry</returns> public UserEntry Insert(UserFeed feed, UserEntry entry) { try { return base.Insert(feed, entry) as UserEntry; } catch (GDataRequestException e) { AppsException a = AppsException.ParseAppsException(e); throw a ?? e; } }
/// <summary> /// Creates a new user account. /// </summary> /// <param name="username">the account's username</param> /// <param name="givenName">the user's first (given) name</param> /// <param name="familyName">the user's last (family) name</param> /// <param name="password">the account's password</param> /// <returns>the newly created UserEntry</returns> public UserEntry CreateUser(string username, string givenName, string familyName, string password) { UserEntry entry = new UserEntry(); entry.Name = new NameElement(familyName, givenName); entry.Login = new LoginElement(username, password, false, false); UserQuery query = new UserQuery(Domain); return(userAccountService.Insert(query.Uri, entry)); }
/// <summary> /// Creates a new user account. /// </summary> /// <param name="username">the account's username</param> /// <param name="givenName">the user's first (given) name</param> /// <param name="familyName">the user's last (family) name</param> /// <param name="password">the account's password</param> /// <param name="passwordHashFunction">the name of the hash function to hash the password</param> /// <param name="quotaLimitInMb">the account's quota, in MB</param> /// <returns>the newly created UserEntry</returns> public UserEntry CreateUser(string username, string givenName, string familyName, string password, string passwordHashFunction, int quotaLimitInMb) { UserEntry entry = new UserEntry(); entry.Name = new NameElement(familyName, givenName); entry.Login = new LoginElement(username, password, false, false, passwordHashFunction); entry.Quota = new QuotaElement(quotaLimitInMb); UserQuery query = new UserQuery(Domain); return(userAccountService.Insert(query.Uri, entry)); }
/// <summary> /// Updates the specified user account. /// </summary> /// <param name="entry">The updated entry; modified properties /// can include the user's first name, last name, username and /// password.</param> /// <returns>the updated UserEntry</returns> public UserEntry UpdateUser(UserEntry entry) { return entry.Update(); }
/// <summary> /// Creates a new user account. /// </summary> /// <param name="username">the account's username</param> /// <param name="givenName">the user's first (given) name</param> /// <param name="familyName">the user's last (family) name</param> /// <param name="password">the account's password</param> /// <param name="passwordHashFunction">the name of the hash function to hash the password</param> /// <param name="quotaLimitInMb">the account's quota, in MB</param> /// <returns>the newly created UserEntry</returns> public UserEntry CreateUser(string username, string givenName, string familyName, string password, string passwordHashFunction, int quotaLimitInMb) { UserEntry entry = new UserEntry(); entry.Name = new NameElement(familyName, givenName); entry.Login = new LoginElement(username, password, false, false, passwordHashFunction); entry.Quota = new QuotaElement(quotaLimitInMb); UserQuery query = new UserQuery(Domain); return userAccountService.Insert(query.Uri, entry); }
/// <summary> /// Creates a new user account. /// </summary> /// <param name="username">the account's username</param> /// <param name="givenName">the user's first (given) name</param> /// <param name="familyName">the user's last (family) name</param> /// <param name="password">the account's password</param> /// <returns>the newly created UserEntry</returns> public UserEntry CreateUser(string username, string givenName, string familyName, string password) { UserEntry entry = new UserEntry(); entry.Name = new NameElement(familyName, givenName); entry.Login = new LoginElement(username, password, false, false); UserQuery query = new UserQuery(Domain); return userAccountService.Insert(query.Uri, entry); }
/// <summary> /// Overridden Delete method that throws AppsException /// </summary> /// <param name="entry">the entry to delete</param> public void Delete(UserEntry entry) { try { base.Delete(entry); } catch (GDataRequestException e) { AppsException a = AppsException.ParseAppsException(e); throw a ?? e; } }
/// <summary> /// Updates the specified user account. /// </summary> /// <param name="entry">The updated entry; modified properties /// can include the user's first name, last name, username and /// password.</param> /// <returns>the updated UserEntry</returns> public UserEntry UpdateUser(UserEntry entry) { return(entry.Update()); }
public void SaveAndReadTest() { LoginElement login = new LoginElement("jdoe"); login.Admin = true; login.HashFunctionName = "SHA-1"; entry.Login = login; QuotaElement quota = new QuotaElement(2048); entry.Quota = quota; NameElement name = new NameElement("Doe", "John"); entry.Name = name; StringBuilder sb = new StringBuilder(); XmlWriter writer = new XmlTextWriter(new StringWriter(sb)); entry.SaveToXml(writer); writer.Close(); XmlDocument document = new XmlDocument(); document.LoadXml(sb.ToString()); UserEntry newEntry = new UserEntry(); foreach (XmlNode node in document.FirstChild.ChildNodes) { ExtensionElementEventArgs args = new ExtensionElementEventArgs(); args.ExtensionElement = node; args.Base = newEntry; newEntry.Parse(args, new AtomFeedParser()); } Assert.AreEqual(login.UserName, newEntry.Login.UserName, "Parsed entry should have same username as original entry"); Assert.IsTrue(newEntry.Login.Admin, "Parsed entry should have admin property set to true"); Assert.AreEqual(login.HashFunctionName, newEntry.Login.HashFunctionName, "Parsed entry should have same hash function name as original entry"); Assert.AreEqual(quota.Limit, newEntry.Quota.Limit, "Parsed entry should have same quota as original entry"); Assert.AreEqual(name.FamilyName, newEntry.Name.FamilyName, "Parsed entry should have same family name as original entry"); Assert.AreEqual(name.GivenName, newEntry.Name.GivenName, "Parsed entry should have same given name as original entry"); }
public void Init() { entry = new UserEntry(); }
public GDataTypes.GDataUserEntry CreateUserEntry(UserEntry userEntry) { var _gDataUserEntry = new GDataTypes.GDataUserEntry(); _gDataUserEntry.UserName = userEntry.Login.UserName; _gDataUserEntry.Admin = userEntry.Login.Admin; _gDataUserEntry.susspended = userEntry.Login.Suspended; _gDataUserEntry.AgreedToTerms = userEntry.Login.AgreedToTerms; _gDataUserEntry.ChangePasswordAtNextLogin = userEntry.Login.ChangePasswordAtNextLogin; _gDataUserEntry.GivenName = userEntry.Name.GivenName; _gDataUserEntry.FamilyName = userEntry.Name.FamilyName; _gDataUserEntry.Limit = userEntry.Quota.Limit; _gDataUserEntry.SelfUri = userEntry.SelfUri.ToString(); return _gDataUserEntry; }
/// <summary> /// Inserts a new user account entry into the feed at the /// specified URI. /// </summary> /// <param name="feedUri">the URI of the feed into which this entry should be inserted</param> /// <param name="entry">the entry to insert</param> /// <returns>the inserted entry</returns> public UserEntry Insert(Uri feedUri, UserEntry entry) { try { return base.Insert(feedUri, entry) as UserEntry; } catch (GDataRequestException e) { AppsException a = AppsException.ParseAppsException(e); throw (a == null ? e : a); } }