I am a little confused on why I can not detect an object that does not exist
with a try and except. If I understand ADSI correctly from what I have read
you do not create these objects but rather get them. They already exist. I
believe if I do the equivalent in VB I would generate an error when I try to
get an object that does not exist (can not find). What have I done wrong?
I have included the function below that works in ever respect but detecting
incorrect NT Domain Names (objects that do not exist) . Any tips, insight or
comments would be welcome by this newbie.
Thx
def CheckNT4(header , all):
adsi = win32com.client .Dispatch('ADsN ameSpaces')
try:
nt = adsi.GetObject( '', "WinNT://"+ frm.NTName) #----->I need some
type of try/except to detect incorrect NT Domain Names
except: print "Domain name failed" # this does not detect a problem
nt.Filter = ['user']
try:
oSID = win32com.client .Dispatch('ADsS id')
except:
MyUsers = [ eauser for eauser in all if eauser[GetPostion(head er,
'STATUS')] is '']
for ea in MyUsers:
ea[GetPostion(head er, 'STATUS')] = 'FailNT'
ea[GetPostion(head er, 'COMMENT')] ='Can not find ADsSid'
MyUsers = [ eauser for eauser in all if eauser[GetPostion(head er,
'STATUS')] is '']
intcnt = 0
for user in nt:
for ea in MyUsers:
if string.upper(us er.Name) == string.upper(ea[GetPostion(head er,
'OLDNTLOGON')]):
frm.MyProgress. Update ( intcnt, 'Found NT user and SID : ' +
user.Name )
intcnt = intcnt+ 1
if user.AccountDis abled:
ea[GetPostion(head er, 'STATUS')] = 'FailNT'
ea[GetPostion(head er, 'COMMENT')] ='Disabled'
else:
if ea[GetPostion(head er, 'COMMENT')] is not '':
ea[GetPostion(head er, 'COMMENT')] = ''
oSID.SetAs (5, "WinNT://"+ frm.NTName + '/' + user.Name)
ea[GetPostion(head er, 'STATUS')] = 'PassNT'
ea[GetPostion(head er, 'Nt4Sid')] = oSID.GetAs(1)
for user in [ eauser for eauser in all if eauser[GetPostion(head er,
'STATUS')] is '']:
user[GetPostion(head er, 'STATUS')] = 'FailNT'
user[GetPostion(head er, 'COMMENT')] = 'NoNt4Account' 1 2591
"LittlePyth on" <Li**********@l ost.com> wrote in message news:al5fg.9877 $ho6.1459@trndd c07... I am a little confused on why I can not detect an object that does not exist with a try and except. If I understand ADSI correctly from what I have read you do not create these objects but rather get them. They already exist. I believe if I do the equivalent in VB I would generate an error when I try to get an object that does not exist (can not find).
I don't get an error when doing a GetObject in VBS
for a nonexistent domain.
What have I done wrong? I have included the function below that works in ever respect but detecting incorrect NT Domain Names (objects that do not exist) . Any tips, insight or comments would be welcome by this newbie.
You should be able to use win32net.NetVal idateName to
verify that the domain exists before doing any more operations.
hth
Roger
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =--- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ondrej Krajicek |
last post by:
Hello,
I have problem with the following code:
rootdse = ldap.OpenDSObject(ROOTDSE_URL, USER_NAME, PASSWORD, opts)
nc = rootdse.Get("defaultNamingContext")
uri = "LDAP://%s/%s" % (SERVER_NAME, nc)
dc = ldap.OpenDSObject(uri, USER_NAME, PASSWORD, opts)
cnUsers = dc.GetObject("top", "Users") ## <-- exception is thrown here
|
by: Miguel Orrego |
last post by:
Hi,
I have found some code that authenticates users agains a domain using ADSI.
I then redirect to another page and pass the username they have entered as a
string. However, it would be nice to also get their full name from Active
Directory once authenticated. Can anyone suggest how I may modify this code
to achieve this? I would also like to pass their full name to the next page
as a string. The code I found:
<%
|
by: Srinivas |
last post by:
Hi,
I've one system in which Active directory is installed.
That system is the domain controller as well as web
server - A test machine.
Trying all following to Authenticate Users using VB as
well as ASP.
I need ASP solution (and no component required etcc..).
Things seems to work fine but stuck badly from past two
days.
|
by: Tom Petersen |
last post by:
My users logon to the Patriot domain, my intranet is on sdsddata01 server.
I have a form that people have to click on a dropdown list to pick their
name from the list when submitting a form. Is there any way to grab their
username via ADSI so I can query it against a database that will get
submitted against a form. I have seen a few arcticles regarding this but I
couldn't make sense of them. They are already authenticating when they...
|
by: Kenneth Keeley |
last post by:
Hi,
Under ASP I was able to use code like that listed below to confirm login
details on our intranet site. I wish to upgrade our site to run purely under
ASP.NET. I am having trouble converting this code to ASP.NET code somebody
point me in the right direction with some sample code like this done in
ASP.NET
set ADSI = GetObject("WinNT:")
set IIS = ADSI.OpenDSObject("WinNT://MyDomain/" & Request.Form("UserName") ,...
| |
by: rias |
last post by:
I'm new to VB.NET and ADSI. By default it appears the adsi limits objects
returned to 1000 items. I've seen web references that say that the limit is
imposed by unpaged queries. I added an explicit pagesize statement, and the
findall.count value went up from 1000 to 4000+ for the OU that I'm querying.
(with considerable added delay in response). However when I try to iterate
through a for-each loop, I still seem to get only 1000 items. ...
|
by: andy |
last post by:
Has anyone ever experienced any problems authenticating with an ADSI application where after so long it stops responding. I can not track down what is causing the problem. I have a login page that uses the following code.
Dim oADsObject
Set oADsObject = GetObject(strADsPath)
Dim strADsNamespace
Dim oADsNamespace
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)
Set...
|
by: Jonathan Smith |
last post by:
I am trying to develop an app using ADSI. I have the following code:
Dim ADSUser As IADsUser
ADSUser = GetObject("LDAP://CN=jonsmith,CN=users,DC=domain,DC=com")
MessageBox.Show(ADSUser.EmailAddress)
When i try and run the program, i get the following error:
|
by: John |
last post by:
Hi, gurus,
How can I implement the following feature in C#:
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group")
For Each objMember In objGroup.Members
WScript.Echo vbCrLf & " Name: " & objMember.Name
Next
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |