I am trying to create a new user -> set password and enable account .
earlier i was using 1 single object , but after looking at a few posts i decided to use 'using' for 3 different operations
string strDisplayName = txtFirstName.Text + " " + txtLastName.Text;
string strUser = txtLoginName.Text;
string pw = "pass#123";
using (var objADAM = new DirectoryEntry("LDAP://" + adlink + "/CN=Users,DC=SS,DC=COM", "ss\\luser", "pass#123", AuthenticationTypes.Secure))
{
const long ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const long ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;
string strPort = "389";
int intPort = Int32.Parse(strPort);
using (var objUser = objADAM.Children.Add("CN=" + strUser, "user"))
{
objUser.Properties["sAMAccountName"].Add(strUser);
objUser.CommitChanges();
}
}
using (var user = new DirectoryEntry("LDAP://" + adlink + "/CN=" + strUser + ",CN=Users,DC=SS,DC=COM", "ss\\rluser", "pass#123"))
{
user.Invoke("SetPassword", new object[] { "password" });
user.CommitChanges();
}
using (var user = new DirectoryEntry("LDAP://" + adlink + "/CN=" + strUser + ",CN=Users,DC=SS,DC=COM", "ss\\rluser", "pass#123"))
{
//Enable account and change password on first logon flag
user.Properties["userAccountControl"].Value = 0x200;
user.Properties["pwdLastSet"].Value = 0;
user.CommitChanges();
}
I must mention, that i am outside the domian, and trying to connect to a remote AD on another domain . The credential's passed however are the ADMIN
The user creation goes on smoothly (after some hiccups with port opening & LDAP connections) , but the issue occurs when the invoke ->setpassword is called .
The error is :"the RPC server is unavailable " , just to make sure i am not doing something wrong in my code, i downloaded a LDAP admin tool and tried to reset the password of an existing user ->same error
steps
-checked the RPC service running
-opened RPC ports -135 ,blah blah..basically every port there is to open :|
any help is appreciated .
Thanks
Rajat
For example:
DirectoryEntry de = new DirectoryEntry();
de.Path = "LDAP://dnsname.domain.com:389/OU=Companies;
Microsoft recommends accessing using DNS.
if the machine you are accessing is connected to a different domain, you must specify it as "ip dnsname" in the hosts file in the "C:\Windows\System32\drivers\etc " directory.
using adlink is string domain, because AD method Invoke using domain name: "abc.com"
Related
I have a c# DOT NET Winforms application that has been working just fine in the developer environment. Yesterday it just stopped working for some reason. No code changes at all. It seems to be timing out while logging in.
private string DocLogin()
{
ErrMsg = string.Empty;
string _accountId = null;
try
{
var _apiClient = new ApiClient(DocuSignURL);
Config = new Configuration(_apiClient);
// configure 'X-DocuSign-Authentication' header
string _authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
Config.AddDefaultHeader("X-DocuSign-Authentication", _authHeader);
// we will retrieve this from the login API call
AuthenticationApi _authApi = new AuthenticationApi(Config);
LoginInformation _loginInfo = _authApi.Login();
_accountId = _loginInfo.LoginAccounts[0].AccountId;
}
catch (Exception ex)
{
_accountId = null;
ErrMsg = ex.Message;
}
return _accountId;
}
As soon as it hits the line "_authApi.Login()" it hangs up then throws the error, "Error calling Login: The operation has timed out".
Any ideas? Remember there has been no code changes and was working fine. I thought about corporate firewall but I tried it outside of the firewall with the same results.
Seems DocuSign stopped TLS1.0 support. See Amit's post above for the link to the solution.
I tried many ways to fix this error :
"Failed to establish a database connection. Check connection string, username and password."
Code :
function AcessaVendas () {
var URL = 'jdbc:sqlserver://servername:49159'
var USER = 'visitant'
var PASS = '*******'
var conn = Jdbc.getConnection(URL, USER, PASS);
var stmt = conn.createStatement();
stmt.setMaxRows(10000);
var start = new Date();
var rs = stmt.executeQuery( myquery());
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Dados");
ss.getRange('a2:h1000').clearContent();
var cell = ss.getRange('a2');
var row = 0;
while (rs.next()) {
for (var col = 0; col < 11; col++) {
cell.offset(row, col).setValue(rs.getString(col + 1));
}
row++;
}
rs.close();
stmt.close();
conn.close();
var end = new Date();
Logger.log('Time elapsed: ' + (end.getTime() - start.getTime()));
}
First i have tried changing the azure servername for the server ip, then i tried adding the database name like,
db = "databasename"
URL = 'jdbc:mysql://servername:49159'+'/'+ db;
I also thought that maybe the database user that i have created in the sql server management studio could be the problem, because he has db_datareader role but i tried using the user with db_owner role and it also didn't work.
I also tried to put every Google App Server IPs whitelist range in the firewall of the azure server(one at once, or do i have to put ervery ip range at once?).
Could someone give me a help?
I'm using PHP and cURL with the REST api, and even though I can cURL the initial Nest Developer api endpoint, once it redirects to Firebase's url it's over port 9553, which my webhost has blocked (no chance to get opened up either). The connection times out and throws the 'could not connect to host' error.
My code is working fine, I can run it on my local server with no problems.
I'm new at using cURL, what are my options? It seems to me that the problem is the port Firebase is insisting on using. I can cURL a number of different locations, over :80 and :443 without problem, just not Firebase's url. Will I need to run through a proxy in order to access the data?
Or, is this something that might be solved by using Firebase's PHP library? I'm not super interested in using it if I don't have to, cURL would do the job nicely, and I don't know really know how it works.
There is no way to get around the redirects with REST, they point to specific ports and hosts in Nest's cloud.
What is wrong with Firebase's Web Sockets client? It is more performant than REST.
joshguerette,
Is your firewall blocking that port?
You can open the port from your c# code with this:
using Microsoft.TeamFoundation.Common;
private void AddPortToFirewall(int portNumber, string name)
{
INetFwMgr icfMgr = null;
try
{
Type TicfMgr = Type.GetTypeFromProgID("HNetCfg.FwMgr");
icfMgr = (INetFwMgr)Activator.CreateInstance(TicfMgr);
}
catch (Exception ex)
{
Debug.WriteLine("Failed in AddPortToFirewall.Activator " + portNumber.ToString() + " " + name + " " + ex.ToString());
return;
}
try
{
INetFwProfile profile;
INetFwOpenPort portClass;
Type TportClass = Type.GetTypeFromProgID("HNetCfg.FWOpenPort");
portClass = (INetFwOpenPort)Activator.CreateInstance(TportClass);
// Get the current profile
profile = icfMgr.LocalPolicy.CurrentProfile;
// Set firewall enabled
if (!profile.FirewallEnabled)
profile.FirewallEnabled = true;
// Set the port properties
portClass.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
portClass.Enabled = true;
portClass.Name = name;
portClass.Port = portNumber;
portClass.Protocol = NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP;
// Add the port to the ICF Permissions List
bool portExisted = false;
foreach (INetFwOpenPort p in profile.GloballyOpenPorts)
{
if (p.Port == portNumber && p.Name == name)
{
portExisted = true;
Debug.WriteLine("Windows Firewall inbound list:" + p.Port + " " + p.Name);
break;
}
}
if (!portExisted)
{
profile.GloballyOpenPorts.Add(portClass);
Debug.WriteLine("ServicePort " + portNumber.ToString() + " " + name + " was added into Windows Firewall inbound list.");
}
else
{
Debug.WriteLine("ServicePort " + portNumber.ToString() + " " + name + " has already in Windows Firewall inbound list.");
}
}
catch (Exception ex)
{
Debug.WriteLine("Failed in AddPortToFirewall " + portNumber.ToString() + " " + name + " " + ex.ToString());
}
}
I'm trying to get user/password from Firebreath plugin with the use of NpapiBrowserHost.GetAuthenticationInfo method.
I need to do this for npapi based browsers (chrome / firefox / opera). So this is my code:
boost::shared_ptr<FB::Npapi::NpapiBrowserHost> npapihost =
FB::ptr_cast<FB::Npapi::NpapiBrowserHost>(m_host);
if(npapihost)
{
char * username = NULL; uint32_t ulen = 0;
char * password = NULL; uint32_t plen = 0;
NPError err = npapihost->GetAuthenticationInfo("http",
"xxx.yyy.com",
80,
"Basic",
"Knownnameofrealm",
&username, &ulen,
&password, &plen );
}
In Opera it works. In Chrome & Firefox it returns err = NPERR_GENERIC_ERROR,
and ulen = 0, plen = 0 (username, password - bad ptr).
This code is executed from MypluginamePlugin::onPluginReady().
If you succeeded in getting credentials, please post code example.
PS Chrome according to chromium sources does not yet implement NPN_GetAuthenticationInfo https://code.google.com/p/chromium/issues/detail?id=23928
In Firefox I should use -1 instead of 80 for http (443 for https).
Simply speaking FF's password managing service stored all it's info inside a hashmap:
Map entry = ( (key to auth. object) , (objects with single user auth. info) )
Each key is a string created as follows: (some pro stuff) + (scheme) + "://" + (host) + ":" + (port).
FF substituted INTERNET_DEFAULT_HTTP_PORT = 80 (INTERNET_DEFAULT_HTTPS_PORT = 443) with -1 while creating new map entry.
In Opera initially all worked fine.
In Chrome browser-side endpoint function is not implemented since stub creation at 2009.
In IE npapihost is not available. Although I didn't even have to mess with login/password extraction because default CInternetSession (wininet package) constructor does it automatically.
I try to increase my instance count by code behind.
First of all I created one .cer file and .pfx file and I upload it into .pfx to cloudservice certificates and .cer to settings --> management certificates.
After I used .cer file in my code. I don't know very well this uplod file is it true ?
Here is my code :
string subscriptionId = "c034e905-......";
string serviceName = "multitenant";
string configFileName = "ServiceConfiguration.cscfg";
string roleName = "Multi.Web";
XNamespace xs = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
XDocument configDocument = XDocument.Parse(String.Join("", File.ReadAllLines(Path.GetFullPath(configFileName))));
XAttribute instanceCountAttribute = configDocument.Element(xs + "ServiceConfiguration")
.Elements(xs + "Role")
.Where(xRole => xRole.Attribute("name").Value == roleName).SingleOrDefault()
.Element(xs + "Instances")
.Attribute("count");
int currentInstanceCount = int.Parse(instanceCountAttribute.Value);
and I am checking some fields in my VM and I incease my currentInstanceCount .
double processorTotal = Convert.ToDouble(performanceCounter.CounterValue);
instanceCountAttribute.Value = (currentInstanceCount + 1).ToString();
var serviceManagment = ServiceManagementHelper.CreateServiceManagementChannel("WindowsAzureEndPoint",
new X509Certificate2("multitenant.cer"));
var changeConfigInput = new ChangeConfigurationInput();
changeConfigInput.Configuration = ServiceManagementHelper.EncodeToBase64String(configDocument.ToString());
try
{
serviceManagment.ChangeConfigurationBySlot(subscriptionId, serviceName, "Production", changeConfigInput);
}
catch (WebException e)
{
throw new Exception(new StreamReader(e.Response.GetResponseStream()).ReadToEnd());
}
ChangeConfigurationBySlot method is throwing exception :
The remote server returned an unexpected response: (400) Bad Request.
Where am I wrong ? I couldn't understand. Is it about method parameters or wrong upload certificate ?
Do you have any estimate?
Thanks.
I solved my problem.
It is not about certification.First I get the production configuration file and I change it's current instance count and redeploy.
Here is the code :
var deployment = managementClient.GetDeploymentBySlot(subscriptionId, serviceName, "Production");
string configurationXml = ServiceManagementHelper.DecodeFromBase64String(deployment.Configuration);
serviceConfiguration = XDocument.Parse(configurationXml);
XNamespace xs = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
instanceCountAttribute = serviceConfiguration.Element(xs + "ServiceConfiguration")
.Elements(xs + "Role")
.Where(xRole => xRole.Attribute("name").Value == roleName).SingleOrDefault()
.Element(xs + "Instances")
.Attribute("count");
currentInstanceCount = int.Parse(instanceCountAttribute.Value);