更改密码不对Asp.Net Core 2的Novell LDAP修改生效

时间:2018-01-16 16:34:33

标签: c# asp.net ldap

对于任何可以提供帮助的人 - 我的代码在Asp/Net Core 2.0中正常工作,可以使用Novell.Directory.Ldap.NETStandard (2.3.8)库向LDAP添加条目。我也更新属性,一切都没有错误。但是,当我更新密码时,它不需要。我无法使用我刚刚通过代码设置的相同密码登录。我想知道是否有人遇到过此问题,我是否需要以特殊方式对其进行编码和/或执行任何其他步骤?

这是我的代码看起来像 - 非常简单,它可以正常工作而不会导致错误:

modList.Add(new LdapModification(LdapModification.REPLACE, new LdapAttribute("pwdLastSet", "-1")));

modList.Add(new LdapModification(LdapModification.REPLACE, new LdapAttribute("userPassword", newPassword)));

LdapModification[] mods = new LdapModification[modList.Count];

mods = (LdapModification[])modList.ToArray(typeof(LdapModification));

string dn = String.Format("CN={0},CN={1},DC=WPD,DC=Local", displayName, "Users");

_conn.Modify(dn, mods);

谢谢! 克雷格

1 个答案:

答案 0 :(得分:0)

我没有使用“ userPassword”属性,而是使用了“ unicodePwd”属性并更改了编码,并且可以正常工作。 重要要点是将密码用双引号引起来。

library(caret)
library(gridExtra)
library(grid)
library(ggridges)
library(ggthemes)
library(iml)
library(partykit)
library(rpart)
library(tidyverse)

theme_set(theme_minimal())
set.seed(88)

kfolds <- 3

load_dataset <- function() {
  dataset <- read_csv("https://gist.githubusercontent.com/dmpe/bfe07a29c7fc1e3a70d0522956d8e4a9/raw/7ea71f7432302bb78e58348fede926142ade6992/pima-indians-diabetes.csv", col_names=FALSE)  %>%
    mutate(X9=as.factor(ifelse(X9== 1, "diabetes", "nondiabetes")))
  X = dataset[, 1:8]
  Y = dataset$X9
  return(list(dataset, X, Y))
}

compute_rf_model <- function(dataset) {
  index <- createDataPartition(dataset$X9,
                               p=0.8,
                               list=FALSE,
                               time=1)

  dataset_train <- dataset[index,]
  dataset_test <- dataset[-index,]

  fit_control <- trainControl(method="repeatedcv",
                              number=kfolds,
                              repeats=1,
                              classProbs=TRUE,
                              savePredictions=TRUE,
                              verboseIter=FALSE,
                              allowParallel=FALSE,
                              summaryFunction=defaultSummary)

  rf_model <- train(X9~.,
                    data=dataset_train,
                    method="rf",
                    preProcess=c("center","scale"),
                    trControl=fit_control,
                    metric="Accuracy",
                    verbose=FALSE)
  return(list(rf_model, dataset_train, dataset_test))
}


main <- function() {
  data <- load_dataset()
  dataset <- data[[1]]
  X <- data[[2]]
  Y <- data[[3]]

  rf_model_data <- compute_rf_model(dataset)
  rf_model <- rf_model_data[[1]]
  dataset_train <- rf_model_data[[2]]
  dataset_test <- rf_model_data[[3]]

  X <- dataset_train    %>%
    select(-X9) %>%
    as.data.frame()

  predictor <- Predictor$new(rf_model, data=X, y=dataset_train$X9)

  ice <- FeatureEffect$new(predictor, feature="X2", center.at=min(X$X2), method="pdp+ice")
  ice_plot_glucose <- ice$plot() + 
    scale_color_discrete(guide="none") +
    scale_y_continuous("Predicted Diabetes")
  ice <- FeatureEffect$new(predictor, feature="X4", center.at=min(X$X4), method="pdp+ice")
  ice_plot_insulin <- ice$plot() + 
    scale_color_discrete(guide="none") +
    scale_y_continuous("Predicted Diabetes")
  grid.arrange(ice_plot_glucose, ice_plot_insulin, ncol=1)

}

if (!interactive()) {
  main()
} else if (identical(environment(), globalenv())) {
  quit(status = main())
}