Class User
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
उपयोगकर्ता
Google Drive में मौजूद किसी फ़ाइल से जुड़ा उपयोगकर्ता. उपयोगकर्ताओं को File.getEditors()
, Folder.getViewers()
, और अन्य तरीकों से ऐक्सेस किया जा सकता है.
// Log the email address of all users who have edit access to a file.
const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
const editors = file.getEditors();
for (let i = 0; i < editors.length; i++) {
Logger.log(editors[i].getEmail());
}
तरीके
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
getDomain() | String | उपयोगकर्ता के खाते से जुड़ा डोमेन नेम पाता है. |
getEmail() | String | उपयोगकर्ता का ईमेल पता पाता है. |
getName() | String | उपयोगकर्ता का नाम दिखाता है. |
getPhotoUrl() | String | उपयोगकर्ता की फ़ोटो का यूआरएल पाता है. |
अब काम न करने वाले तरीके
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
getUserLoginId()
| String | उपयोगकर्ता का ईमेल पता पाता है. |
ज़्यादा जानकारी वाला दस्तावेज़
getDomain()
उपयोगकर्ता के खाते से जुड़ा डोमेन नेम पाता है.
// Log the domain names associated with all users who have edit access to a
// file.
const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
const editors = file.getEditors();
for (let i = 0; i < editors.length; i++) {
Logger.log(editors[i].getDomain());
}
वापसी का टिकट
String
— उपयोगकर्ता के खाते से जुड़ा डोमेन नेम
getEmail()
उपयोगकर्ता का ईमेल पता पाता है. उपयोगकर्ता का ईमेल पता सिर्फ़ तब उपलब्ध होता है, जब उपयोगकर्ता ने Google+ खाते की सेटिंग पेज से पता शेयर करने का विकल्प चुना हो. इसके अलावा, यह तब भी उपलब्ध होता है, जब उपयोगकर्ता उसी डोमेन से जुड़ा हो जिस डोमेन से स्क्रिप्ट चलाने वाले उपयोगकर्ता का जुड़ाव है. साथ ही, डोमेन एडमिन ने डोमेन के सभी उपयोगकर्ताओं को दूसरे उपयोगकर्ताओं के ईमेल पते देखने की अनुमति दी हो.
// Log the email address of all users who have edit access to a file.
const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
const editors = file.getEditors();
for (let i = 0; i < editors.length; i++) {
Logger.log(editors[i].getEmail());
}
वापसी का टिकट
String
— उपयोगकर्ता का ईमेल पता या अगर ईमेल पता उपलब्ध नहीं है, तो खाली स्ट्रिंग
getName()
उपयोगकर्ता का नाम दिखाता है. अगर उपयोगकर्ता का नाम उपलब्ध नहीं है, तो यह तरीका null
दिखाता है.
// Log the names of all users who have edit access to a file.
const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
const editors = file.getEditors();
for (let i = 0; i < editors.length; i++) {
Logger.log(editors[i].getName());
}
वापसी का टिकट
String
— उपयोगकर्ता का नाम या नाम उपलब्ध न होने पर null
getPhotoUrl()
उपयोगकर्ता की फ़ोटो का यूआरएल पाता है. अगर उपयोगकर्ता की फ़ोटो उपलब्ध नहीं है, तो यह तरीका null
दिखाता है.
// Log the URLs for the photos of all users who have edit access to a file.
const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
const editors = file.getEditors();
for (let i = 0; i < editors.length; i++) {
Logger.log(editors[i].getPhotoUrl());
}
वापसी का टिकट
String
— उपयोगकर्ता की फ़ोटो का यूआरएल या फ़ोटो उपलब्ध न होने पर null
अब काम न करने वाले तरीके
getUserLoginId()
अब काम नहीं करता. 24 जून, 2013 से, इसे getEmail()
से बदल दिया गया है.
उपयोगकर्ता का ईमेल पता पाता है.
// Log the email address of the person running the script.
Logger.log(Session.getActiveUser().getUserLoginId());
वापसी का टिकट
String
— उपयोगकर्ता का ईमेल पता.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eA User in Google Drive represents an individual associated with a file or folder, accessible through methods like \u003ccode\u003egetEditors()\u003c/code\u003e and \u003ccode\u003egetViewers()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve user information such as their domain, email address, name, and photo URL using dedicated methods of the \u003ccode\u003eUser\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetUserLoginId()\u003c/code\u003e method is deprecated and has been replaced by \u003ccode\u003egetEmail()\u003c/code\u003e for accessing a user's email address.\u003c/p\u003e\n"],["\u003cp\u003eUser email addresses might not be available if privacy settings restrict access or if domain-wide sharing isn't enabled.\u003c/p\u003e\n"],["\u003cp\u003eUser names and photo URLs may return \u003ccode\u003enull\u003c/code\u003e if they are not available or have not been set by the user.\u003c/p\u003e\n"]]],[],null,["# Class User\n\nUser\n\nA user associated with a file in Google Drive. Users can be accessed from [File.getEditors()](/apps-script/reference/drive/file#getEditors()), [Folder.getViewers()](/apps-script/reference/drive/folder#getViewers()), and other methods.\n\n```javascript\n// Log the email address of all users who have edit access to a file.\nconst file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst editors = file.getEditors();\nfor (let i = 0; i \u003c editors.length; i++) {\n Logger.log(editors[i].getEmail());\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------|-------------|----------------------------------------------------------|\n| [getDomain()](#getDomain()) | `String` | Gets the domain name associated with the user's account. |\n| [getEmail()](#getEmail()) | `String` | Gets the user's email address. |\n| [getName()](#getName()) | `String` | Gets the user's name. |\n| [getPhotoUrl()](#getPhotoUrl()) | `String` | Gets the URL for the user's photo. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|-------------|--------------------------------|\n| [getUserLoginId()](#getUserLoginId()) | `String` | Gets the user's email address. |\n\nDetailed documentation\n----------------------\n\n### `get``Domain()`\n\nGets the domain name associated with the user's account.\n\n```javascript\n// Log the domain names associated with all users who have edit access to a\n// file.\nconst file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst editors = file.getEditors();\nfor (let i = 0; i \u003c editors.length; i++) {\n Logger.log(editors[i].getDomain());\n}\n```\n\n#### Return\n\n\n`String` --- the domain name associated with the user's account\n\n*** ** * ** ***\n\n### `get``Email()`\n\nGets the user's email address. The user's email address is only available if the user has\nchosen to share the address from the Google+ account settings page, or if the user belongs to\nthe same domain as the user running the script and the domain administrator has allowed all\nusers within the domain to see other users' email addresses.\n\n```javascript\n// Log the email address of all users who have edit access to a file.\nconst file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst editors = file.getEditors();\nfor (let i = 0; i \u003c editors.length; i++) {\n Logger.log(editors[i].getEmail());\n}\n```\n\n#### Return\n\n\n`String` --- the user's email's address, or a blank string if the email address is not available\n\n*** ** * ** ***\n\n### `get``Name()`\n\nGets the user's name. This method returns `null` if the user's name is not available.\n\n```javascript\n// Log the names of all users who have edit access to a file.\nconst file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst editors = file.getEditors();\nfor (let i = 0; i \u003c editors.length; i++) {\n Logger.log(editors[i].getName());\n}\n```\n\n#### Return\n\n\n`String` --- the user's name, or `null` if the name is not available\n\n*** ** * ** ***\n\n### `get``Photo``Url()`\n\nGets the URL for the user's photo. This method returns `null` if the user's photo is not\navailable.\n\n```javascript\n// Log the URLs for the photos of all users who have edit access to a file.\nconst file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');\nconst editors = file.getEditors();\nfor (let i = 0; i \u003c editors.length; i++) {\n Logger.log(editors[i].getPhotoUrl());\n}\n```\n\n#### Return\n\n\n`String` --- the URL for the user's photo, or `null` if the photo is not available\n\nDeprecated methods\n------------------\n\n### `get``User``Login``Id()`\n\n\n**Deprecated.** As of June 24, 2013, replaced by [getEmail()](#getEmail()).\n\nGets the user's email address.\n\n```javascript\n// Log the email address of the person running the script.\nLogger.log(Session.getActiveUser().getUserLoginId());\n```\n\n#### Return\n\n\n`String` --- The user's email's address."]]