Skip to content

Commit f2ca3c0

Browse files
authored
Merge pull request DOI-NPS#142 from RobLBaker/master
add function get_user_orcid
2 parents badc597 + 051f2e7 commit f2ca3c0

47 files changed

Lines changed: 118 additions & 53 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export(get_dp_flags)
1818
export(get_elevation)
1919
export(get_park_polygon)
2020
export(get_taxon_rank)
21+
export(get_user_orcid)
2122
export(get_utm_zone)
2223
export(long2UTM)
2324
export(order_cols)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* create_datastore_script modified to allow upload of large (>32mb) repos
88

99
# QCkit v1.1.0
10+
## 2025-07-25
11+
* add function `get_user_orcid`, which will look up a users orcid using active directory.
12+
1013
## 2025-05-16
1114
* create_datastore_script now invisibly returns the DataStore reference URL
1215

R/utils.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,34 @@ get_user_email <- function() {
6969

7070
return(email_address)
7171
}
72+
73+
#' Returns the user's ORCID ID from active directory
74+
#'
75+
#' @description
76+
#' This is a function to grab a users ORCID from Active Directory. Requires VPN to access AD. If the user does not have an ORCID, returns "NA".
77+
#'
78+
#'
79+
#' @returns Sting. The user's ORCID ID
80+
#' @export
81+
#'
82+
#' @examples
83+
#' \dontrun{
84+
#' orcid <- get_user_orcid()
85+
#' }
86+
get_user_orcid <- function() {
87+
powershell_command <- '([adsisearcher]\\"(samaccountname=$env:USERNAME)\\").FindAll().Properties'
88+
89+
AD_output <- system2("powershell",
90+
args = c("-Command",
91+
powershell_command),
92+
stdout = TRUE)
93+
#get extensionAttribute2 (holds orcid)
94+
orcid <- AD_output[which(AD_output %>%
95+
stringr::str_detect("extensionattribute2"))]
96+
# extract orcid
97+
orcid <- stringr::str_extract(orcid, "\\{.*?\\}")
98+
# remove curly braces:
99+
orcid <- stringr::str_remove_all(orcid, "[{}]")
100+
101+
return(orcid)
102+
}

docs/404.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CONTRIBUTING.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/DRR_Purpose_and_Scope.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/Starting-a-DRR.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/Using-the-DRR-Template.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)