|
Have just tested my old code and with the same account admin and pass i created the AD member with same username and password with the same 3 not created issues...then I deleted the AD member and attempted again with the code provided...no go...
I am really dumb struck...
|
|
|
|
|
OK, try passing Nothing as the password parameter to the UserPrincipal constructor. Then, after calling user.Save() , call user.SetPassword(Password) , followed by another user.Save() call.
Using user As New UserPrincipal(context, UserName, Nothing, True)
...
user.Save()
user.SetPassword(Password)
user.Save()
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried it and received a new error at the same place in the code
The supplied arguments cannot be null.
Thanks for persisting with me...
|
|
|
|
|
That's annoying.
Try the constructor that doesn't take the username and password as arguments:
Using user As New UserPrincipal(context)
user.SamAccountName = UserName
user.Name = UserName
user.Enabled = True
...
user.Save()
user.SetPassword(Password)
user.Save()
...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi again Richard,
I will definitely try this on Monday and report. Thanks again and enjoy your weekend
|
|
|
|
|
Start of a new week, Hi Richard,
I have tried the change as you suggested but keep getting a "The user name or password is incorrect"
Truly hope you might have another suggestion...
|
|
|
|
|
Hi Richard,
still receives error "The user name or Password is incorrect"
hope you have another idea still
thanks
|
|
|
|
|
No. The code I posted seems to work for everyone else, so I can only assume there's something odd with your setup.
All I can suggest is that you try using your previous code to create the user, and use the new code to update the properties that you couldn't set:
Using context As New PrincipalContext(ContextType.Domain)
Using user As UserPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.Name, UserName)
If user IsNot Nothing Then
user.PasswordNeverExpires = True
user.UserCannotChangePassword = True
user.HomeDrive = HomeDrive
user.HomeDirectory = HomeDirectory
user.ScriptPath = ScriptPath
user.Save()
Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(context, IdentityType.Name, MemberOf)
If group IsNot Nothing Then
group.Members.Add(user)
group.Save()
End If
End Using
End If
End Using
End Using
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is excellent, thank you so much...it all works 100%.
One question only, please: When the 'user logon name' is inserted it has a drop down box with the domain listed. When I insert the username the drop-down is not selected with the domain...is there a way I can set this value.
Thanks again
|
|
|
|
|
According to this StackOverflow answer[^], you need to include the domain in the UserPrincipalName property:
Utility.SetProperty(myDirectoryEntry, "UserPrincipalName", "some.user@your.domain.local")
user.UserPrincipalName = "some.user@your.domain.local"
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard,
Truly thank you for enduring with me on this issue. I have resolved all shortcomings I had and everything is inserted 100%.
Big thumbs up.
|
|
|
|
|
i want to make security system for university need help??
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
You need to specify a whole load more than that - and tell us what you have done so far as well.
Then tell us what help you need.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
How do you know you need help? It doesn't appear as if you've even started.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
guys,
I need to design a web page with file upload option in asp net mvc.
my requirement is, have few text boxes, dropdown list and need to upload file to support that data. these things to be save in db, and have generate that page dynamically.
Thanks
|
|
|
|
|
This is just a partial list of requirements. It is not a question or a description of a problem. Perhaps you can reword your posting to include a question, a description of a problem and make it sound less like you expect us to write your code for you (because we won't). And, in the future, posting in the appropriate forum might be better. There are web programming forums that might be a better fit for whatever question you actually have.
|
|
|
|
|
im beginner to mvc. im just asking basic idea, like how.
|
|
|
|
|
|
Dani_el wrote: im beginner to mvc. im just asking basic idea, like how.
The basic idea is to read tutorials, read articles, read books, take some classes at your local college or university. Reading how to get an answer to your question[^] might not be a bad idea either.
|
|
|
|
|
Hi,
I'm writing an unmanaged application, and, am using the provided COM interfaces to invoke .NET Framework class methods. Generally, this works well, although the code is tedious to write. IPGlobalProperties is an abstract .NET class, and the GetIPGlobalProperties method is static. I am able to obtain a _MethodInfo interface pointer by invoking _Type.GetMethod_6 on the IPGlobalProperties type. Then, when I attempt to invoke _MethodInfo.Invoke_3, providing a bstr "GetIPGlobalProperties", the application crashes with an access violation. The same thing happens when I call _MethodInfo.QueryInterface, providing the IID for the _MethodBase interface (which succeeds), and, then invoking _MethodBase.Invoke_3.
I'm thinking, maybe, I should be calling: _Type.InvokeMember, or something along these lines.
Previously in my code, I had no problem obtaining a NetworkInformationPermission object by calling its constructor, and providing a NetworkInformationAccess value of read, so I'm wondering what is the reason for the access violations.
modified 31-Aug-16 17:04pm.
|
|
|
|
|
0) Did you mean to say that IPGlobalProperties is a static class?
1) If you're calling IPGlobalProperties.GetIPGlobalProperties() , why aren't you referring directly to the properties contained in the return object instead of trying to find/invoke an appropriate Get method?
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Hi, John,
By writing an unmanaged application, I'm actually using only COM interfaces to access .NET Framework classes. For Instance: the _Type interface All the various COM interfaces provide methods to access .NET objects, but, the syntax is different from C#. In my application, I obtain a COM interface pointer for the DefaultDomain (after loading the version 4 CLR), then, use that with the _AppDomain interface to call GetAssemblies. This returns a SAFEARRAY of _Assembly Interface pointers, which I can use to call GetTypes. Also, I can invoke: _AppDomain.Load, with an assembly Display Name, and this succeeds in loading a .NET assembly into the AppDomain. And, it goes on from there.
Anyway, once you have an interface pointer to a Type, you can call GetConstructors, which returns a SAFEARRAY of _ConstructorInfo interface pointers. In this case (IPGlobalProperties), which is an abstract class, the GetConstructors method returns a SAFEARRAY with NO interface pointers,...so, it is impossible to invoke the constructor and then call GetIPGlobalProperties with an instance of IPGlobalProperties.
...In C#, you would do this (from the NetStat .NET Framework SDK Code Sample):
IPGlobalProperties ipGlobal = IPGlobalProperties.GetIPGlobalProperties();
I don't have Visual Studio installed on my computer. But, my COM application (which I'm writing in assembly language), I would attempt to invoke GetIPGlobalProperties using: _MethodInfo.Invoke, or one of the other Invoke overloads (after invoking _Type.GetMethod, which succeeds). GetIPGlobalProperties is a static method, with no parameters, so the parameters to Invoke are NULL.
When I call it, though (_MethodInfo.Invoke), it crashes my application with an access violation.
modified 31-Aug-16 17:11pm.
|
|
|
|
|
Why don't you write a "COM-visible" .Net assembly that retrieves the info you want, and expose a COM interface that allows you to retrieve the properties. I think that would be less painful than trying to coerce the .Net class directly (and you can expand the .NET assembly to provide more functionality any time you need to.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Greetings...
The problem is simple: In a ASP.NET GridView, if the property e.Row.Parent.ClientID is used in the RowDataBound event, .NET generates another identifier for the GridView, and if you had javascripts in your page that used the ClientID for the GridView, they wont work.
To replicate the problem, you have to create a WebForm with one GridView, one Client HTML Button has to access the GridView identifier like this:
<input id="Button1" type="button" value="Test" onclick="alert('The next message does not have to be null: ' + document.getElementById('<%=gridViewTest.ClientID %>'))" />
If in gridViewTest_RowDataBound you don't use the e.Row.Parent.ClientID property, everything will be fine, but if you use e.Row.Parent.ClientID for some purpose, .NET will generate another ID for the GridView and the HTML Button will not work anymore.
Is that the expected behavior, or it is a bug?
modified 24-Aug-16 10:00am.
|
|
|
|
|
Is there a question in there?
This space for rent
|
|
|
|
|